Combining Tables

A

Adam

I have 12 tables with 12 months of data. The fields names in each table are
exactly the same (incident number, date, etc.), with the data in each table
representing a month of data. How do I combine these 12 tables into one
table?
 
B

Ben

do a UNION query:

select * from tbl1
UNION
select * from tbl2
....
UNION
select * from tb12

Note: Union queries automatically removes the dups from all the tables.


Ben
 
R

RonaldoOneNil

Why do you need to combine into 1 table ?
Create a union query which selects the data from the 12 tables.
SELECT * FROM [TableNameforMonth1];
UNION ALL SELECT * FROM [TableNameforMonth2];
UNION ALL SELECT * FROM [TableNameforMonth3];
etc.
 
K

KARL DEWEY

You might want it like this --
SELECT *, 1 AS Month_All FROM [TableNameforMonth1]
UNION ALL SELECT *, 2 AS Month_All FROM [TableNameforMonth2]
UNION ALL SELECT *, 3 AS Month_All FROM [TableNameforMonth3]
......
UNION ALL SELECT *, 12 AS Month_All FROM [TableNameforMonth12];

--
KARL DEWEY
Build a little - Test a little


RonaldoOneNil said:
Why do you need to combine into 1 table ?
Create a union query which selects the data from the 12 tables.
SELECT * FROM [TableNameforMonth1];
UNION ALL SELECT * FROM [TableNameforMonth2];
UNION ALL SELECT * FROM [TableNameforMonth3];
etc.

Adam said:
I have 12 tables with 12 months of data. The fields names in each table are
exactly the same (incident number, date, etc.), with the data in each table
representing a month of data. How do I combine these 12 tables into one
table?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top