title: Drupal 7 - case-insensitive LIKE with db_select
body: <p>I can't get a query to be case-insensitive using MySQL and Drupal 7.  Here's my module code:</p>
  
  <pre><code>$results = db_select('people_table', 'p')-&gt;fields('p');
  if (array_key_exists('department', $_GET)) {
      $results-&gt;condition('Department', '%' . db_like($_GET['department']) . '%', 'LIKE');
  }
  return $results-&gt;orderBy('Name', 'ASC')-&gt;execute();
  </code></pre>
  
  <p>With <code>?department=Chemistry</code> in the URL, I get three results.  With <code>?department=chemistry</code> in the URL, I get no results.  When I try <code>$results-&gt;condition('UPPER(Department)'...</code>, I get this error:</p>
  
  <blockquote>
    <p>PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'UPPERDepartment' in 'where clause': SELECT p.* FROM {people_table} p WHERE (UPPERDepartment LIKE :db_condition_placeholder_0 ESCAPE '\\') ORDER BY Name ASC; </p>
  </blockquote>
  
  <p>So it looks like it eats my parentheses.  How can I do a case-insensitive <code>LIKE</code>?</p>
  
  <p><strong>Edit:</strong>  the collation on the <code>Department</code> column as well as on the whole table is <code>utf8_bin</code>.  <a href="https://stackoverflow.com/questions/367711/what-is-the-best-collation-to-use-for-mysql-with-php/367725#367725">This answer</a> says "The only special one is utf8_bin which is for comparing characters in binary format."  I don't know why this collation was chosen, since all the data in the table is English text.  I might just change the collation to <a href="http://dev.mysql.com/doc/refman/5.5/en/charset-charsets.html" rel="nofollow noreferrer">utf8_general_ci</a>.</p>