Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
2  
Short answer: "Yes, that is possible." For an answer that also answers the implied "How?" you will need to supply more information. Where is the second table right now (in a file, in the same DB under a different name)? How do you plan on identifying "duplicates"? –  Johannes Pille Mar 31 '13 at 11:29
    
The second DB is in a .sql file. I plan to identify duplicates with the 'post_content' field. –  drake035 Mar 31 '13 at 13:02

1 Answer 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.