Merging two wp_posts tables while avoiding duplicates

Is there a simple way to merge two wp_posts tables while avoiding duplicates?

Related posts

Leave a Reply

1 comment

  1. Import the new table as wp_posts_2, then join them and delete all duplicates based on post_content; then merge the two tables.

    The following SQL query (untested!) should give the posts from the new table to be deleted:

    SELECT wp2.* FROM wp_posts_2 as wp2 LEFT JOIN wp_posts as wp ON wp2.post_content = wp.post_content WHERE wp2.post_content = wp.post_content
    

    So, you can delete the entries with this query (also untested):

    DELETE wp_posts_2.* LEFT JOIN wp_posts as wp ON wp_posts_2.post_content = wp.post_content WHERE wp_posts_2.post_content = wp.post_content
    

    Then merge the two tables.