Search code examples
phpmysqlxmlcase-sensitivecase-insensitive

Case Sensitivity Problem with PHP and MySQL


I am trying to return an XML list from a MySQL database via PHP and am having issues with case sensitivity. Here is the current code I'm using

$query = "SELECT * FROM FOO WHERE FOO LIKE '%$term%' ORDER BY FOO";

In my database I have first names listed as "Joe" so in order to return the XML I have to enter $term as "Joe". I can't use "joe" or "JOE" but would like to. I'm not sure if I can accomplish this directly through the PHP or whether I need to adjust the MySQL table.


Solution

  • SELECT  *
    FROM    foo
    WHERE   foo COLLATE UTF8_GENERAL_CI LIKE '%$term%'
    ORDER BY
            foo