How to change strings in MySQL tables
Posted on In QAHow to change strings in MySQL tables? e.g. I want to change domain.com to www.domain.com.
Use the REPLACE functions of MySQL: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace
One example is like this:
UPDATE table
SET field = REPLACE(field, 'domain.com', 'www.domain.com')
WHERE field LIKE '%domain.com%'
The WHERE clause is not needed but can make execution faster.