Hi, John.
I have three tables with a common id with which they can be linked. I need to
merge them
.. . .
How can I go about doing this?
One way to do it is by building five queries. In this example, the three tables
are named TableC, TableD, and TableE.
Create the first query and name it qryUnionAllIDs:
SELECT ID
FROM TableC
UNION
SELECT ID
FROM TableD
UNION
SELECT ID
FROM TableE
ORDER BY ID;
Create the second query and name it qryAllTableC:
SELECT qryUnionAllIDs.ID, TableC.Value1
FROM qryUnionAllIDs LEFT JOIN TableC
ON qryUnionAllIDs.ID = TableC.ID;
Create the third query and name it qryAllTableD:
SELECT qryUnionAllIDs.ID, TableD.Value2
FROM qryUnionAllIDs LEFT JOIN TableD
ON qryUnionAllIDs.ID = TableD.ID;
Create the fourth query and name it qryAllTableE:
SELECT qryUnionAllIDs.ID, TableE.Value3
FROM qryUnionAllIDs LEFT JOIN TableE
ON qryUnionAllIDs.ID = TableE.ID;
Create the fifth query and run it to create tblValuesFromTablesCDE:
SELECT * INTO tblValuesFromTablesCDE
FROM (SELECT qryAllTableC.ID,
qryAllTableC.Value1, qryAllTableD.Value2,
qryAllTableE.Value3
FROM (qryAllTableC INNER JOIN qryAllTableD
ON qryAllTableC.ID = qryAllTableD.ID)
INNER JOIN qryAllTableE
ON qryAllTableD.ID = qryAllTableE.ID);
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact info.
"John" <Jo**@nospam.infovis.co.ukwrote in message
news:eo**************@TK2MSFTNGP06.phx.gbl...
Hi
I have three tables with a common id with which they can be linked. I need to
merge them in a way that the resultant table has all records from three
tables. Below is what sort of result I am expecting;
Table 1
ID Value1
1 A1
Table 2
ID Value2
1 A2
2 B2
Table 1
ID Value3
2 B3
3 C3
Result expected;
ID Value1 Value2 Value3
1 A1 A2 <blank>
2 <blank B2 B3
3 <blank <blank C3
Columns are blank where no records match for that table.
How can I go about doing this?
Thanks
Regards