Michael Gaigg: Über UI/UX Design

4Mar0

Using REPLACE in a SQL UPDATE

Posted by Michael Gaigg

When moving domains there will be a need to replace old url's and other strings to reflect the new names.

In my case the images of my blog articles were still pointing to the old domain which didn't physically exist anymore. Result: broken images and links.

Quick Solution

A quick SQL replace does the trick:

UPDATE blog_posts SET post_content = REPLACE(post_content, 'old-server.com', 'new-server.com') WHERE post_content LIKE '%old-server.com%'

This SQL statement is perfect for updating wordpress blogs that moved to a different domain/host.

Easy and efficient 🙂

2May0

Highlights of Week 17/2011

Posted by Michael Gaigg