Please keep backup before doing any update in database.
So this is very import to know, how to update database after moving wordpress website from one domain to another. For example
Suppose that in you are working on local server and after completion of project, you have uploaded all files on your live server along with local server database. Then here you need to run some query to update old url with new url.
Old url = http://www.oldsiteurl.com
New ulr = http://www.newsiteurl.com
Now here is some query to update old url with new url
Change Siteurl & Homeurl
If you transfer your WordPress site from the localhost to your server, your site will not load online, because the absolute path URL is still pointing to your localhost server. You will need to change the site URL and the home URL.
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';
After you have migrated your website from the localhost to your server or from old domain to a new domain, then you will need to fix the URLs for the GUID field in wp_posts table. This is crucial because GUID is used to translate your post or page slug to the correct article absolute path if it is entered wrongly.
UPDATE wp_posts SET guid = REPLACE (guid, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');
Change URL in Content
WordPress uses absolute path in the URL link instead of a relative path in the URL link when saving them into the database. Therefore you will need to change all old URLs to the new domain url.
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');
Change Image Path Only
If you decide to use Amazon CloudFront as your Content Delivery Network (CDN) to offload the delivery of images from your server. After your have created your CNAME record, you can use the query below to change all the image paths in WordPress to load all your images from Amazon CloudFront.
wp_posts SET post_content = REPLACE (post_content, 'src="http://www.oldsiteurl.com', 'src="http://yourcdn.newsiteurl.com');
You will also need to update the GUID for Image Attachment with the following query:
UPDATE wp_posts SET guid = REPLACE (guid, 'http://www.oldsiteurl.com', 'http://yourcdn.newsiteurl.com') WHERE post_type = 'attachment';
Update Post Meta
Okay so here is updating post meta works almost the same way as updating the URL in post content. If you have stored extra URL data for each post, then you can use the follow query to change all of them.
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://www.oldsiteurl.com','http://www.newsiteurl.com');