joining tables

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
 
S

Steve Schapel

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
 
J

John Spencer (MVP)

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.
 
M

M.L. Sco Scofield

If the table structures are in fact identical, you can save some typing by
using:

TABLE Accounts2003
UNION ALL
TABLE Accounts2004

Sco
 
M

M.L. Sco Scofield

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

Sco
 
M

M.L. Sco Scofield

Cool!

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

Sco
 
M

M.L. Sco Scofield

Cool!

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

Sco
 
Top