When keeping multiple versions of a website, or perhaps migrating a website to a new environment, it is often necessary to merge any changes between the two databases. The databases have the same structure, but each has new, unique content which needs to be added to the other. The following tutorial uses syntax for MySQL, however it should be applicable to other major database schemas. The following example assumes that the master database where we want all of the changes to reside is called database1, and the table we want to merge is called mytable, The secondary database with the changes to be merged is called database2. This command can be executed from within phpMyAdmin or from the MySQL command line:
This will insert all of the new data from database2.mytable, while excluding any duplicates.





