Find and Replace text in the entire table using a MySQL query

alyasabrina picture alyasabrina · Aug 7, 2012 · Viewed 492.3k times · Source

Usually I use manual find to replace text in a MySQL database using phpmyadmin. I'm tired of it now, how can I run a query to find and replace a text with new text in the entire table in phpmyadmin?

Example: find keyword domain.com, replace with www.domain.com.

Answer

swapnesh picture swapnesh · Aug 7, 2012

For a single table update

 UPDATE `table_name`
 SET `field_name` = replace(same_field_name, 'unwanted_text', 'wanted_text')

From multiple tables-

If you want to edit from all tables, best way is to take the dump and then find/replace and upload it back.