开发者

Case Sensitivity Problem with PHP and MySQL

开发者 https://www.devze.com 2023-03-20 12:57 出处:网络
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

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 开发者_JS百科directly through the PHP or whether I need to adjust the MySQL table.


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消