tags:

views:

60

answers:

2

Hi there, im trying to do a comparison in MYSQL but wish for it to be case sensitive

ex:

$userID="test"
$q = db_query("select * from users where user_id = '" .  $userID  . "'");

In DB:

userid = "TEST"

Ho do i go about making sure the mysql query does not return TRUE for this query as the userid varialbe doesnt match the case of the userid in the database

thanks

+1  A: 

You can force to compare with case sensitivity using COLLATE

http://dev.mysql.com/doc/refman/5.0/en/charset-collate.html

You can also use BINARY

SELECT * FROM users WHERE BINARY user_id = '%John%'

Raj More
+1  A: 

The MySQL manual explains possible solutions quite well.

Mads Jensen