How to find and replace text in a MySQL Database using SQL

Lets say you have a word or reference you need to change within one (or several) column(s) in one of your tables. The following SQL statement will then come in very handy and may be applied using one of your SQL admin tools. I personally use phpMyAdmin, but any tool or command line should work.

UPDATE table_name SET column_name = replace( column_name, 'from_old_value', 'to_the_new_value' );

This post was written in the hope that it may prove useful for someone, and also as a “reminder” to myself as I seem to forget this simple yet powerful SQL statement 🙂

About Author