How to find and replace text in a MySQL database

Solution for : How to find and replace text in a MySQL database

I have a column containing urls (id, url):

http://www.example.com/articles/updates/123
http://www.example.com/articles/updates/345
http://www.example.com/articles/updates/234

I'd like to change the word "updates" to "events". Is it possible to do this with a script?

QUERY: We can achieve the above requirements using below query.

UPDATE your_table
SET your_field = REPLACE(your_field, 'articles/updates/', 'articles/events/')
WHERE your_field LIKE '%articles/updates/%'

No comments:

Post a Comment