Why Mysql doesn't handle case sensitive cases

When I test below sql queries:

    1.  SELECT * FROM  table WHERE  username='username' AND password = 'password';

    2.  SELECT * FROM  table WHERE  username='Username' AND password = 'Password';

      

Both queries return the same result even if the username and password are case sensitive

+3


source to share


2 answers


Use this query



SELECT * FROM  table WHERE  username='Username' AND binary password = 'Password';

      

+3


source


Syntax for Query Based on Case

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

      



In your case, this would become:

SELECT * FROM  table WHERE BINARY username='Username' AND BINARY password = 'Password';

      

+3


source







All Articles