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/articles/updates/323 http://www.example.com/articles/updates/seo-url http://www.example.com/articles/updates/4?something=test
I'd like to change the word "updates" to "news". Is it possible to do this with a script?
MySQL REPLACE() FunctionThe REPLACE() function replaces all occurrences of a substring within a string, with a new substring. Note: This function performs a case-sensitive replacement.
You could simply use: UPDATE customers_basket SET products_id=CONCAT('S', SUBSTRING(products_id FROM 2)); i.e.: Instead of replacing the initial "U" with an "S", simply start with an "S" and copy the remaining characters.
UPDATE your_table SET your_field = REPLACE(your_field, 'articles/updates/', 'articles/news/') WHERE your_field LIKE '%articles/updates/%'
Now rows that were like
http://www.example.com/articles/updates/43
will be
http://www.example.com/articles/news/43
http://www.electrictoolbox.com/mysql-find-replace-text/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With