Jerry Swanson wrote:

Column type is username varchar(100).

When I do select from database:
        "select * from user where username='John'";  //returns one row
        "select * from user where username='john'"; //returns one row

The records in the database has username 'John'.

Why it  isn't case sensitive? 'John" and 'john' .. are two different strings..?

Because it isn't. String comparisons are case insensitive by default in mysql <http://dev.mysql.com/doc/mysql/en/case-sensitivity.html>.

If you want a case-sensitive comparison, you need to say so with BINARY:

  SELECT * FROM user WHERE username = BINARY 'John'.

If you want *ALL* comparisons of the username column to be case sensitive, then you should declare it as a BINARY type.

  username VARCHAR(100) BINARY

or

  username VARBINARY(100)

See the manual for details:
<http://dev.mysql.com/doc/mysql/en/char.html>
<http://dev.mysql.com/doc/mysql/en/binary-varbinary.html>

Michael

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to