Question

Possible Duplicate:
mysql case sensitive query

'm working on an PHP script that checks some values to the ones in the database. So far I thought it worked right, but I found an problem.

The query isn't looking for the specific characters.

So if I use this query:

SELECT *
FROM `facilitydb_login`
WHERE
facilitydb_login.`password` = 'PASS'

I want the result, because the password is PASS. But if you fill in pass (lowercase) the same entry is returned.

How can I make it case sensitive?

Was it helpful?

Solution

you should use case sensitive collation, for example

SELECT *
FROM `facilitydb_login`
WHERE facilitydb_login.`password` collate latin1_general_cs = 'PASS'

CS in the name means that it's Case Sensitive

OTHER TIPS

you could make the column case sensitive

Assume you are using mysql database

ALTER TABLE facilitydb_login 
CHANGE password `password` VARCHAR(100) BINARY NOT NULL;

or If you want to make part of the select statement then

SELECT *
FROM `facilitydb_login`
WHERE BINARY 
facilitydb_login.`password` = 'PASS'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top