user3264863 user3264863 - 4 months ago 10
SQL Question

how to search record in mysql with special characters

I use MySQL where in table i have three record like this

ABC10%DEF
XYZ10GKSLK
CKALK143LK


Now i want to search where it finds word '10%' in record. so here it should return only "ABC10%DEF". But it shows me two record "ABC10%DEF" and "XYZ10GKSLK" because in search term i have used % sign. How to ignore this "%" in search result so that it can consider % as searching character rather than wildcard characters.

Answer

You shuould escape the %

 select * from my_table 
 where my_column like '%10\%%'