Case sensitive selects in MySQL

There has been a couple of reasons recently that I needed to do a look up on a MySQL table using a case-sensitive Select statement. Its actually as easy as using "LIKE BINARY" instead of "LIKE" e.g.

view plain print about
1SELECT username, password
2FROM tablename
3WHERE password LIKE BINARY 'SOmE PAssWOrD'
Obviously if you are on a CFML engine don't forget
<cfqueryparam cfsqltype="cf_sql_varchar" value="SOmE PAssWOrD" />

Posted: 13-Jan-2010

View: 1564

Permalink: here

Comments

Oh very nice; I have never seen this construct before. Someone once showed me how to do something with a CAST() as Binary (I think) - but the LIKE BINARY seems nicer to me.

#1 Ben Nadel
17/Feb/10 6:17 PM