SQL queries update WordPress URLs

Update site url in wp_options

UPDATE wp_options 
SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') 
WHERE option_name = 'home' OR option_name = 'siteurl';

Update guid

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');

Update all urls in post content

UPDATE wp_posts 
SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');

Update all urls in meta fields

UPDATE wp_postmeta 
SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');