joining tables

  • Thread starter Thread starter stu
  • Start date Start date
S

stu

Hi. Can anyone help?!



I have two identical tables (accounts2003 and accounts2004) though one
contains last year's data, and the other contains this year's data. The
tables aren't joined in any way, other than that they contain the same
columns.



Is there any way I can create a query that displays both tables in one list?



Many thanks in advance.



Stu
 
Stu,

This can be done with a Union Query. A Union Query can't be created
with the Access query design view, it has to be done directly in SQL.
It will look something like this...
SELECT 1stField, 2ndField, 3rdField
FROM Accounts2003
UNION
SELECT 1stField, 2ndField, 3rdField
FROM Accounts2004
 
Small point, but it may be important. Use UNION ALL vice UNION. Using UNION
would eliminate rows that have identical contents across all fields. Probably
would not happen, but it could.

SELECT * FROM Accounts2003
UNION ALL
SELECT * FROM Accounts2004

Of course, if Accounts2003 and Accounts2004 don't have exactly parallel
structure the all fields "*" indicator will cause an error and you will have to
fall back on specifically listing the fields in a parallel order.
 
If the table structures are in fact identical, you can save some typing by
using:

TABLE Accounts2003
UNION ALL
TABLE Accounts2004

Sco
 
On behalf of Steve and John, we're all glad that we were able to help.

Sco
 
Cool!

Hard to believe I was able to pass something along to you and John S.

Sco
 
Cool!

Hard to believe I was able to pass something along to you and Steve S.

Sco
 
Back
Top