简体   繁体   中英

mysql match special character % from a text

I have to select all rows from a table where column (varchar) values contain '%' in the text. I tried below query but failed to get correct result set.

SELECT * from TABLE where VALUE LIKE '%%%'

Above query gives all rows of the table.

Please help me to form a query to match '%' and get the correct results.

SELECT * FROM your_table 
WHERE value LIKE '%\\%%'

SQLFiddle demo

Escape character worked for me.

SELECT * from TABLE where VALUE LIKE '%\%%'

This query gives me correct result set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM