How do you force mysql LIKE to be case sensitive? [duplicate]

Possible Duplicate:
Mysql Like Case Sensitive

Mysql ignores case for its LIKE comparisons.

How can you force it to perform case-sensitive LIKE comparisons?


Use LIKE BINARY:

mysql> SELECT 'abc' LIKE 'ABC';
    -> 1
mysql> SELECT 'abc' LIKE BINARY 'ABC';
    -> 0

Another alternative is to use COLLATE,

SELECT *
FROM table1
WHERE columnName like 'a%' COLLATE utf8_bin;
  • SQLFiddle Demo