I want to update a table with a new url to replace the old one:
UPDATE table1
SET column1 = REPLACE(column1, 'OLD URL', 'NEWURL')
WHERE column LIKE '%OLDURL%'
This updates it mostly but I only want to replace part of it, and if I put any / in it doesn’t work, so if I want to use:
UPDATE table1
SET column1 = REPLACE(column1, 'OLD URL/folder1', 'NEWURL')
WHERE column LIKE '%OLDURL%'
It doesn’t work because of the the /
.
2
Answers
The quickest fix to your second update query is to just include the path component in the replacement:
You should check for the replacement pattern in the
where
:I’m not sure if that addresses what you mean by “doesn’t work”, though.