The LIKE statement is used for searching records with partial strings in MySQL. By default the query with LIKE matches case-insensitive recores. Means query will match both records in lowercase or uppercase.
For example, Search all records un colors table where name is start with “Gr”.
mysql> SELECT name FROM colors WHERE name LIKE 'Gr%';
You can see the above query matches records with any cases.
But, sometimes you need to select case-sensitive data only. In that case, You need to cast the values as binary.
To do this add BINARY option with like statment and view the results:
mysql> SELECT name FROM colors WHERE name LIKE BINARY 'Gr%';
You can see the result contains only those records, which matches extactly with case-sensitive. When we use BINARY, then mysql compare data byte-by-byte. Without BINARY it compares data character-by-character.