Menu Close

Replace strings in SQL tables by query

Sometimes you need to fix some information or data in a table with SQL. Here some examples of queries I used to fix or change data. Example template:

UPDATE `table_name` SET `field_name` = replace(same_field_name, 'unwanted_text', 'wanted_text')

Using this example template to replace a specific string in WordPress database posts:

UPDATE `wp_posts` SET `post_content` = replace(post_content, 'https://www.myoldserver.com', 'www.mynewserver.com')

Leave a Reply

Your email address will not be published.