Performing MySQL query with case sensitivity

Let us take note of the following example data.


Note that the first row is in all lower case, the second in proper case, and the third contains all capitalized letters. If we run a normal MySQL select statement to search for “dev-notes” such as the below, the system will return all three records.

/* Standard query; not case sensitive */
select * from mytable where website_name='';

To get around it, simply use the “binary” keyword before the column name, shown in the example below.

/* Case sensitive query */
select * from mytable where binary website_name='';

The query above will only return the first record, which is the one that contains all lower case letters.

Leave a Reply

Your email address will not be published. Required fields are marked *