We were recently tasked with updating the name of a company on various pages of a large content managed website. This task could’ve taken quite some time and I found myself thinking how easy it would be if the site were static and I could do a simple find and replace or search and replace.
I started doing this by hand… until my brain engaged and I realized how easy it would be to do with a simple MySQL query. Using MySQL’s built in replace function I wrote the following query to do a string replace operation that replaces old_string with new_string for all occurrences within a particular column.
UPDATE table_name SET column_name = replace(column_name, 'old_string', 'new_string');
This was a quick and painless way to update a large data set.