DEV Community

Ganesh Dhumal
Ganesh Dhumal

Posted on

Answer: Update a column value, replacing part of a string

UPDATE yourtable
SET url = REPLACE(url, 'http://domain1.example/images/', 'http://domain2.example/otherfolder/')
WHERE url LIKE ('http://domain1.example/images/%');

relevant docs: http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_replace

Top comments (0)