Using SELECT REPLACE with MySQL - Mysql Views : 463
Tagged in : Mysql
0 0
Send mail
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');
By Rekha, On - 2010-01-28



    Login to add Comments .