I have a column containing urls (id, url):
http://www.example.com/articles/updates/43
http://www.example.com/articles/updates/866
http://www.example.com/arti
In addition to gmaggio's answer if you need to dynamically REPLACE
and UPDATE
according to another column you can do for example:
UPDATE your_table t1
INNER JOIN other_table t2
ON t1.field_id = t2.field_id
SET t1.your_field = IF(LOCATE('articles/updates/', t1.your_field) > 0,
REPLACE(t1.your_field, 'articles/updates/', t2.new_folder), t1.your_field)
WHERE...
In my example the string articles/news/
is stored in other_table t2
and there is no need to use LIKE
in the WHERE
clause.