How do you force mysql LIKE to be case sensitive?

MysqlSqlCase SensitiveSql Like

Mysql Problem Overview


> Possible Duplicate:
> Mysql Like Case Sensitive

Mysql ignores case for its LIKE comparisons.

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

Mysql Solutions


Solution 1 - Mysql

Use LIKE BINARY:

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

Solution 2 - Mysql

Another alternative is to use COLLATE,

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBohemianView Question on Stackoverflow
Solution 1 - MysqlBohemianView Answer on Stackoverflow
Solution 2 - MysqlJohn WooView Answer on Stackoverflow