1

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

newguy
  • 13
  • 2
  • possible duplicate of [case insensitive for sql LIKE wildcard statement](http://stackoverflow.com/questions/2876789/case-insensitive-for-sql-like-wildcard-statement) – OMG Ponies Jun 09 '10 at 19:22

2 Answers2

3

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
  • 47,048
  • 33
  • 131
  • 198
0

The MySQL manual explains possible solutions quite well.

Mads Mogenshøj
  • 2,063
  • 1
  • 16
  • 23