Forum Moderators: coopster

Message Too Old, No Replies

Case sensitive

         

babloo

9:42 am on Oct 6, 2004 (gmt 0)

10+ Year Member



Hello,

I need a small help here. I need to know how to control the case sensitive in mysql query. I have a record in the table which is in uppercase. For eg. this is a sample records "TESTDATA". If someone searches for "testdata" the query should return 0 rows. But here it is returning the row. I want to know how to use the case sensitivity here. Please help and Thankyou.

Babloo

Netizen

12:20 pm on Oct 6, 2004 (gmt 0)

10+ Year Member



You will need to amend the column definition - you can specify whether a text column is binary or not which means that searches on it will be case sensitive.

ALTER thetable MODIFY thecolumn char(n) binary;

should do the trick, where n is the current size of the field you need to amend.

coopster

1:22 pm on Oct 6, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Or, you can make sure that one of the operands is a BINARY [dev.mysql.com] string:

SELECT * FROM thetable WHERE BINARY thecolumn LIKE 'testdata%';
or
SELECT * FROM thetable WHERE thecolumn LIKE BINARY 'testdata%';