merging multiple tables?

romanticode

Registered User.
Local time
Today, 18:29
Joined
Oct 26, 2007
Messages
39
I have data that splite by month, so january data separated from february data, an so on.
can i display those data on one table by using query?
if yes.how can i do that?

thanks
 
Yes it can be done if the table structure for your tables is the same you can use a union query. the easiest way to make one is building the query for one month in the QBE grid the switch to SQL view add Union to the end and add the next month.

Why are you storing your data in separate tables?
 
i still dont get the point. can u show me the example where to place the union statement?

thnks
 
Have you looked up Union queries in Access help?
 
Create a normal select query - and put all your fields into the query.

Now change to SQL view and your query should look like this:
SELECT Jan1.fldDate, Jan1.field1, Jan1.field2
FROM Jan1;

Now update the SQL to look like this:

SELECT fldDate, field1, field2
FROM Jan1
UNION ALL SELECT fldDate, field1, field18
FROM Feb1;

This will paste Feb1 table onto the bottom of Jan1 table.
If you miss out the ALL clause then any duplicated rows are left out.

Each field must be in the same order, and must be the same data type. They can have different names and the final query will use the names of the first table.

If you use:
SELECT *
FROM Jan1
UNION ALL SELECT *
FROM Feb1;

Then each table must have the same number of fields.
 
The real solution is to keep all the data in a single table. What are you going to do come January? Are you going to keep adding new tables for the new year as well?
 

Users who are viewing this thread

Back
Top Bottom