开发者

how to ensure comparison is case sensitive?

开发者 https://www.devze.com 2023-01-03 09:26 出处:网络
im trying to do a comparison in MYSQL but wish for it to be case sensiti开发者_如何转开发ve ex:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消