tags:

views:

65

answers:

3

Hi guys, I'm running a SQL query on my mysql database but for some reason its case sensitive like if an entry exists as 'NAME = Andrew' running a sql query like:

SELECT * WHERE NAME Like 'and%'

Doesn't work but

SELECT * WHERE NAME Like 'And%'

does work? WHat gives I'm running a php mysql set up here...

+6  A: 

It depends on your field's collation. For instance if you use utf8_general_ci for the 'name' field, it would be case insensitive on that query.

Alex
utf8_genderal_ci will also treat "He%" and "She%" as equal. ;)
Pekka
in particular, collations containing near the end _ci are case insensitive, and those containing _cs are case sensitive
Vinko Vrsalovic
Sorry for that genderal typo ;-)
Alex
WHOA! Spot on - my fields we collated with utf8_bin - I'll change them to something which ends with ci :) Thanks for the tip...
Ali
A: 

From the MySQL Dev Site

"Normally, if any expression in a string comparison is case sensitive, the comparison is performed in case-sensitive fashion. "

Martin Hohenberg
A: 

Normally, if any expression in a string comparison is case sensitive, the comparison is performed in case-sensitive fashion.

http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html

Yet, someone thinks it is a bug http://bugs.mysql.com/bug.php?id=8847

Tzury Bar Yochay