user525429
user525429

Reputation: 57

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.

Upvotes: 3

Views: 471

Answers (2)

Quassnoi
Quassnoi

Reputation: 425823

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

Upvotes: 5

Jeff Parker
Jeff Parker

Reputation: 7517

A bit of a cheaty answer, but someone else went to the trouble of writing this out already.

http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html

Upvotes: 2

Related Questions