MySQL query combine 3 tables into 1
Posted on 2011-10-12
I need the actual SQL command to perform the following operation using MySQL 5.x.
I have 4 tables: Table1, Table2, Table3 and Table4 all with the exact same structure/columns.
How do I formulate a SQL query to select ALL records from the first 3 tables and using the following columns from the first 3 tables, keep only one instance of any duplicate records and then insert that record and all other records into Table4?
Columns to compare are: STREET_NUMBER, STREET_NAME, STREET_TYPE, STREET_DIRECTION, UNIT_NUMBER, CITY, ZIP_CODE
Actual columns are: ID, STATE, NAME, STREET_NUMBER, STREET_NAME, STREET_TYPE, STREET_DIRECTION, UNIT_NUMBER, CITY, ZIP_CODE