MySQL Search Replace

Author: Zeeshan Arshad     923     09/06/2015

Estimated reading time: 0 minutes, 15 seconds

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

Solution Query: 

UPDATE [table_name] SET [field_name] = REPLACE([field_name], "foo", "bar");

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


Was this topic helpful?

Yes
No
Subscribe YouTube Channel

Zeeshan is a multi-talented serial freelacncer, specialist in custom apps/cms/automation scripts and online instructor.

Feel free to contact him with your clear message or problem.

Story  LinkedIn Profile  Courses  YouTube