im trying to do a comparison in MYSQL but wish for it to be case sensiti开发者_如何转开发ve
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
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%'
The MySQL manual explains possible solutions quite well.
精彩评论