30 Jun 2016

select only uppercase or lowercase records from mysql table

The table A contains following two records ‘222a’ and ‘222A’, 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 : 
222a
222A
 
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. 

SELECT * FROM  table_A WHERE binary value =  '111A'
 
Output : 222A 



No comments :

Post a Comment