SQL to replace URLs in common WordPress tables

Use this script when moving from one URL to another to catch the most common places where a URL is embedded:

SET @oldurl := "oldurl.com";
SET @newurl := "newurl.com";
UPDATE wp_posts
SET post_content = REPLACE(post_content, @oldurl, @newurl)
WHERE post_content LIKE CONCAT('%',@oldurl,'%');
UPDATE wp_options
SET option_value = REPLACE(option_value, @oldurl, @newurl)
WHERE option_value LIKE CONCAT('%',@oldurl,'%');
UPDATE wp_postmeta
SET meta_value = REPLACE(meta_value, @oldurl, @newurl)
WHERE meta_value LIKE CONCAT('%',@oldurl,'%');