How to find and replace in MySQL

Find and replace text is quite simple in MySQL.

In this example we will be replacing "£" with "£"

First use a select query to make sure your replacing is working correctly:

SELECT REPLACE(Field, "£", "£") FROM table WHERE Field REGEXP "£";

If this outputs the expected rows you can then issue:

UPDATE table SET Field = REPLACE(Field, "£", "£") WHERE Field REGEXP "£";

Last updated: 26/08/2006