If you ever need to search and replace text within a MySQL database, there is a simple function available to achieve this by using the REPLACE() command.
REPLACE() allows you to modify one string value in a table for another.
They syntax is straightforward: REPLACE(text_string, from_string, to_string)
This command will search for all instances of “from_string” and modify it to the value of “to_string”.
This is a very useful and time saving command if you have the need to search and replace text which affect a large portion of your database. For example, if a user change phone number, if a company changes name, if you need to correct a typo, etc…
Keep in mind, the REPLACE() command is case-sensitive.
You can also specifically select the table to modify.
For example:
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘from_string’, ‘to_string’);