MySQL search and replace some text in a field
mysql, replace, search, sql
Solution
Change `table_name` and `field` to match your table name and field in question:
UPDATE table_name SET field = REPLACE(field, 'foo', 'bar') WHERE INSTR(field, 'foo') > 0;
- REPLACE (string functions)
- INSTR (string functions)
Problem
What MySQL query will do a text search and replace in one particular field in a table? I.e. search for `foo` and replace with `bar` so a record with a field with the value `hello foo` becomes `hello bar`.