Tanu Gupta
Tanu Gupta

Reputation: 612

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.

Upvotes: 0

Views: 41

Answers (2)

Tanu Gupta
Tanu Gupta

Reputation: 612

Escape character worked for me.

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

This query gives me correct result set.

Upvotes: 0

juergen d
juergen d

Reputation: 204746

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

SQLFiddle demo

Upvotes: 1

Related Questions