Case sensitive String Comparison in MySql Table

Usually the MySql Queries are Case insensitive. The default character set and collation are latin1 and latin1_swedish_ci, so nonbinary string comparisons are case insensitive by default. This means that if you search with col_name LIKE ‘a%’, you get all column values that start with A or a.

This can be performed with mysql query . For this you have to use .

SELECT * FROM `table` WHERE BINARY `column` = 'value';

To acheive this in phpmyadmin , you can change the language collation to latin1_general_cs
If you want a column always to be treated in case-sensitive fashion, declare it with a case sensitive or binary collation.

Example :

SELECT * FROM users_table;

id first_name Email
1 mahran mahran@gmail.com
2 John John@xxx.com
3 john john@yyy.com
4 Gill NULL

4 rows in set (0.001 sec)


SELECT * FROM users_table WHERE `first_name` ='John';
id first_name Email
1 John John@xxx.com
2 john john@yyy.com

2 rows in set (0.00 sec)

SELECT * FROM users_table WHERE BINARY `first_name` ='John';

id first_name Email
1 John John@xxx.com

1 rows in set (0.00 sec)
mysql>