title: Combine LIKE within an IN statement in SQL?
body: <p>Hey guys I have a query which currently takes a list of keywords from a form and returns the top 5 matching associated statements. These are in two different tables (<code>Keyword</code> &amp; <code>Problem</code>). The problem Im having is that if someone searches for TURNS a result is returned but if you search for TURN there are no results. I know this seems simple but the query I'm working with is a little less so. This is the query I'm working with:</p>
  
  <pre><code>SELECT p.*, pc.wordCount, pc.commonCount    
  FROM Problem p INNER JOIN (
  SELECT p.Problem_Identity, COUNT(k.Keyword_Identity) AS "wordCount",
  SUM(k.Keyword_Common) as "commonCount"
  FROM( SELECT * FROM Keyword ) k
  INNER JOIN KeywordsInProblem kip ON (k.Keyword_Identity = kip.Keyword_Identity)
  INNER JOIN Problem p ON (p.Problem_Identity = kip.Problem_Identity)
  WHERE UCASE(k.Keyword_Word) IN(\''. strtoupper(implode("', '", $keyArr)) .'\')
  GROUP BY p.Problem_Identity) pc
  ON (p.Problem_Identity = pc.Problem_Identity) where pc.commonCount &gt; 0
  ORDER BY pc.wordCount DESC, pc.commonCount DESC LIMIT 5
  </code></pre>
  
  <p>PS: the  <code>$keyArr</code> variable is one which explodes the form input statement in order to sanitize it before using it in the database.</p>