How to make mysql select query case sensitive

Case Sensitive SQL

A normal sql select query performs case-insensitive query which means if the user name is raj,Raj,RAJ then it will select all users using simple select. Below query is a normal mysql select query -

SELECT * FROM tablename WHERE username=’raj’

But if you want a query to be case sensitive then you can use following query-

SELECT * FROM tablename WHERE BINARY username =’raj’

this will select only those user that exactly matches with user name raj and not Raj and RAJ.

Hope this will help you – Enjoy !!