tags:

views:

892

answers:

3

What Mysql query will do a text search and replace in one particular field in a table?

ie search for 'foo' and replace with 'bar' so a record with a field with the value : 'hello foo' becomes: 'hello bar'.

A: 

Replace will do that

Wayne
+1  A: 

UPDATE table_name SET field = replace(field,'[string-to-find]','[string-that-will-replace-it]');

thesmallprint
+8  A: 
update table set field = replace(field, 'foo', 'bar') where instr(field, 'foo') > 0;
Joe Skora
perfect answer, thanks.
julz