Wednesday, July 4, 2012

Mysql LIKE backslash with wildcard character

Searching for backslash is tricky in MySQL when you are using the wildcard character. The simple like '%\%' does not produce the expected output. You have to add more backslashes. So to find any field that contains backslash the correct syntax is:

select * from table where field = '%\\\\%'

No comments:

Post a Comment