Combining content from two sites.
WHEN THIS ARISES
Consolidating two sites into one Recovering content from a backup without a full restore Bringing staging content into production
THE DIFFICULTY
Primary keys collide. Both databases have a post with id 1, and they are different posts.
Simply importing one into the other does not work.
THE PRACTICAL APPROACHES
Use the application's own export and import. WordPress has an exporter producing a file that imports into another site, reassigning ids correctly.
That is far safer than working at the database level.
For specific rows, insert them without their original id, letting the destination assign new ones. Then fix any references.
WHAT MAKES IT HARD
Relationships. A post references its author, its categories and its metadata by id. All of those must be remapped.
This is why application-level tools exist.
BEFORE ATTEMPTING IT
Back up both databases.
Work on a copy of the destination, not the live site.
IF IT IS COMPLEX
This is developer work. A partial merge that corrupts relationships is worse than not starting.