Transfer WP from subdomain to main domain

After copying to the main-directory change the values in then wp-config.php and .htaccess files for the new localtion. Then you have to change the values in the database. You need 3 SQL-Statements, which you can execute with phpMyAdmin for example.

First change the options-Table

UPDATE wp_options
SET option_value = replace(option_value, 'http://www.example.com/subdir', 'http://www.example.com')
WHERE option_name="home" OR option_name="siteurl";

Second change the values for the guid in the posts-table

UPDATE wp_posts
SET guid = replace(guid, 'http://www.example.com/subdir', 'http://www.example.com');

Third change the URL in the posts-Table

UPDATE wp_posts
SET post_content = replace(post_content, 'http://www.example.com/subdir', 'http://www.example.com');

If you have used another prefix then wp_ you have to change it in the 3 SQL-Statements. Pay attention at the example domain-names, too.