Home | Blog | Twitter @AndyJ | Contact Me | Snippets/Downloads | RSS

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 plainprintabout
 SELECT username, password
 FROM tablename
 WHERE password LIKE BINARY 'SOmE PAssWOrD'
Obviously if you are on a CFML engine don't forget
<cfqueryparam cfsqltype="cf_sql_varchar" value="SOmE PAssWOrD" />
TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Ben Nadel's Gravatar 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.
# Posted By Ben Nadel | 2/17/10 6:17 PM
BlogCFC / created by Raymond Camden / running version 5.9.5.003 / Contact AndyJarrett.com / Pet Rescue SOS www.redgiraffes.co.uk