Site icon SmartTutorials.net

How to select only uppercase or lowercase records from mysql table

The table A contains following two records ‘111a’ and ‘111A’, if you want to select only ‘111A’ record using following those queries it will outputs both the records instead outputting single records.

Queries are

SELECT * FROM  table_A WHERE value =  '111A'

SELECT * FROM  table_A WHERE value LIKE '%A'

Output are

MySql Table Output

Here is the solution to select only uppercase or lowercase letter records from your table. In the below sql query the BINARY operator casts the string following it to a binary string. This is an easy way to force a comparison to be done byte by byte rather than character by character in where condition.

Query

SELECT * FROM  table_A WHERE binary value =  '111A'

Output

Query

SELECT * FROM  table_A WHERE binary value =  '111a'

Output

 

 .

Exit mobile version