WordPress SQL query change domain

When you moving a WordPress site, from a local installation, to a new domain or another domain, you can use this tool to facilitate the work and obtain an SQL code to execute.

Prefix
Old Domain
New Domain
From localhost?
UPDATE {{ prefix }}_options SET option_value = REPLACE(option_value, '{{ firstDomain }}', '{{ secondDomain }}') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE {{ prefix }}_posts SET post_content = REPLACE (post_content, '{{ firstDomain }}', '{{ secondDomain }}');
UPDATE {{ prefix }}_posts SET post_excerpt = REPLACE (post_excerpt, '{{ firstDomain }}', '{{ secondDomain }}');
UPDATE {{ prefix }}_postmeta SET meta_value = REPLACE (meta_value, '{{ firstDomain }}','{{ secondDomain }}');
UPDATE {{ prefix }}_termmeta SET meta_value = REPLACE (meta_value, '{{ firstDomain }}','{{ secondDomain }}');
UPDATE {{ prefix }}_comments SET comment_content = REPLACE (comment_content, '{{ firstDomain }}', '{{ secondDomain }}');
UPDATE {{ prefix }}_comments SET comment_author_url = REPLACE (comment_author_url, '{{ firstDomain }}','{{ secondDomain }}');
UPDATE {{ prefix }}_posts SET guid = REPLACE (guid, '{{ firstDomain }}', '{{ secondDomain }}') WHERE post_type = 'attachment';