title: Make Mysql Query Case Insentive
body: <p>Is it possible to make the following query string case insensitive?</p>
  
  <pre><code>SELECT SUBSTR(raw,INSTR(raw,'".$term."') - 50,350) as term,
  (LENGTH(raw) - LENGTH(REPLACE(raw,'".$term."',''))) /LENGTH('".$term."') AS occur,name,title 
  FROM ( 
       SELECT ( LENGTH(raw) - LENGTH(REPLACE(raw,'".$term."','')) ) / LENGTH('".$term."') AS occur, raw, consol.name,title 
       FROM consol 
       WHERE LENGTH(raw) - LENGTH(REPLACE(raw,'".$term."',''))&gt;0 AND raw LIKE '%".$term."%' COLLATE utf8_general_ci ORDER BY occur DESC 
       ) t ";
  </code></pre>
  
  <p>The engine for the table is MyISAM and the encoding is UTF8. When i run the query from the command line it works, but when I execute it through the browser it throws the following error.</p>
  
  <blockquote>
    <p>Notice: failed Query : COLLATION 'utf8_general_ci' is not valid for CHARACTER SET 'latin1' in</p>
  </blockquote>
  
  <p>The table is encoded in UTF-8 with the collation of utf8_general_ci.  How can I ensure that a query of "small" matches small as well as Small or SMALL ?</p>