MySQL table merge
June 14, 2011 2:01 PM Subscribe
How does one go about merging disparate MySQL tables? (Blockheaded amateur question)
posted by Electrius to computers & internet (12 answers total) 1 user marked this as a favorite
I've tried reading about this online, but no luck in figuring it out so far. I have four different tables, each with their own primary key. I need to map the differently-named fields from each table onto a fifth table, which will give all the entries new primary-key ID numbers while conserving their old ID numbers. Each of the four tables has different columns and some columns only exist in one table; these will be left NULL in the "result" table.
My question is this: is there some command that I can feed a map of the different columns and have it do it magically, or do I have to manually write some kind of copy-paste algorithm? If it's easier to do this with a PHP script of some type, I can do that instead-- the tables aren't live and performance of this task isn't an issue. I've also read about the UNION command, but I don't know how to dump that into a table of its own, or if it can do everything I need it to do.
I cannot understand the written tutorials in a way that would permit me to answer this question by reading them. I don't know why this is (allergies? insufficient brain power?), but I need someone to explicitly explain the answer to me. Thank you for your time.