MySQL replace function – Find and replace values in database with sql

A great piece of sql that can save you a lot of time. The replace sql function finds and replaces values in a database.

Just fill in the table_name, table_field, the value your searching for and with which value you want to replace it with.

UPDATE table_name SET table_field = REPLACE(table_field, 'value', 'new_value') WHERE my_field LIKE '%value%';

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s