Using SELECT REPLACE with MySQL
by Rekha[ Edit ] 2010-01-28 14:12:02
You can find and replace text in mysql using REPLACE function.
The REPLACE() function takes three parameters:
1. the string or column name to do the replacement on
2. what to look for
3. and what to replace it with
The following example replaces the 'aaa' part of 'aaa bbb ccc' with 'xyz' and the column returned from the SQL query will contain 'xyz bbb ccc':
SELECT REPLACE('aaa bbb ccc', 'aaa', 'xyz');
If you were doing this against the column "foo" you would do this instead:
SELECT REPLACE(foo, 'aaa', 'xyz');