Skip to content

How to escape slashes in LIKE clause

I need to do some clean-up in a database and change some urls from to, so I am doing a query like this:

UPDATE mytable set url = REPLACE(url, '""', '""')

the double comma is needed as this strings are part of a JSON string

however, the problem is that in the DB the old url is for some reason escaped so I have something like this

if I run a query like these they don’t match anything

select * from mytable where url like '%'
select * from mytable where url like '%'

and therefore the replace query doesn’t work either, so what’s the correct way to escape these strings?



You might try:

where url like '%http:\/\/'

To be honest, I don’t understand how or why forward slashes would be escaped. Perhaps you are better off just using a wildcard:

where url like '%http:_/_/'
6 People found this is helpful