views:

359

answers:

3

I have an MS access database file with 2 tables: t1, t2. Both have primary key, suppose id, but t1 has 3 columns A, B and C, while t2 has columns D, E AND F.

Both have the same rows, but each has different columns as stated.

What is the easiest way to merge these two tables? Note that they are very big, and exporting to excel, CSV and such is not acceptable.

A: 

This can all be accomplished using only the Access GUI.

a. Edit t1, and add the two new columns.

b. In Querydef design mode for an Update querydef, pull up both tables, and join them on id.

c. Update the two new columns in t1 with the same two from t2.

d. Execute the querydef (F5).

Done!

le dorfier
A: 

does access support unions?

select a,b,c from t1
union
select d as a, e as b and f as c from t2
Riho
Access doesn't support anything. Jet SQL supports UNION.
David-W-Fenton
The Access Data Engine (ACE) indeed supports UNION and Microsoft's own documentation declares that the UNION operator "applies to Access2007" (http://office.microsoft.com/en-gb/access/HA012315211033.aspx).
onedaywhen
+1  A: 

If you paste SQL like so:

SELECT t1.ID, t1.a, t1.b, t1.c, t2.d, t2.e, t2.f 
INTO t0
FROM t1 INNER JOIN t2 ON t1.ID = t2.ID;

Into the SQL view of a query design window in Access, you will have a make table query that will create t0 from t1 and t2.

Remou