mghhgm mghhgm - 3 years ago 122
MySQL Question

MySQL select by difference between lowercase and uppercase characters

I have table like this:

Table name: hash_table
id hash
1 abc
2 aBc
3 abC
4 AbC
5 ABc

There is difference between lowercase and uppercase characters. For example

In this query, return all rows:

SELECT * FROM `hash_table` WHERE `hash` = "abc"

By search in stackoverflow, some answers talk about
use in select query but they return all rows.

Is there a way to return only correct row?

Answer Source

String comparision could ve performed in sql in two distinct way ..binary and not binary .. If you don't cast binary .. the comparision is case insentive .. if you useing binary the comparision is done by byte and the is also case sensitive ..

try using

SELECT * FROM `hash_table` WHERE BINARY `hash` = BINARY "abc"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download