How to Join 2 queries

M

maryfung25

Dear All,

Please advise how to join 2 queries which their field name is a bit
different but the content is more or less the same.

Table structure
6-Address Type(1) 6-Address Type(2) 6-Street(1&2) 6-Second Addr
Line(1&2) 6-County
Code(1&2) 6-City(1&2) 6-Province(1&2) 6-Country(1&2) 6-Postal Code(1&2)


The different between the follow queries are select either .[6-Address
Type(1)], [6-Address Type(2)] .

Query1:SELECT Template.[0-Staff Number], Template.[0-Start Date],
Template.[0-End Date], Template.[6-Address Type(1)],
Template.[6-Street(1&2)], Template.[6-Second Addr Line(1&2)],
Template.[6-County Code(1&2)], Template.[6-City(1&2)],
Template.[6-Province(1&2)], Template.[6-Country(1&2)], Template.[6-Postal
Code(1&2)]
FROM Template
ORDER BY Template.[0-Staff Number] DESC;

Query2:
SELECT Template.[0-Staff Number], Template.[0-Start Date], Template.[0-End
Date], Template.[6-Address Type(2)], Template.[6-Street(1&2)],
Template.[6-Second Addr Line(1&2)], Template.[6-County Code(1&2)],
Template.[6-City(1&2)], Template.[6-Province(1&2)],
Template.[6-Country(1&2)], Template.[6-Postal Code(1&2)]
FROM Template
ORDER BY Template.[0-Staff Number] DESC;


But I want to have a query or table that canjoin these queries together.

6-Address Type(1&2) 6-Street(1&2) 6-Second Addr Line(1&2) 6-County
Code(1&2) 6-City(1&2) 6-Province(1&2) 6-Country(1&2) 6-Postal Code(1&2)

Please help. Thanks
 
B

Brent Spaulding \(datAdrenaline\)

There is no need to JOIN the two queries since they are from the same source
("Template") ... so just go into design view of either one of them and drag
the fields you want into the column grid.
 
P

pietlinden

Dear All,

Please advise how to join 2 queries which their field name is a bit
different but the content is more or less the same.

Table structure
6-Address Type(1)       6-Address Type(2)       6-Street(1&2)      6-Second Addr
Line(1&2)   6-County
Code(1&2)   6-City(1&2) 6-Province(1&2)     6-Country(1&2)      6-Postal Code(1&2)

The different between the follow queries are select either .[6-Address
Type(1)], [6-Address Type(2)] .

Query1:SELECT Template.[0-Staff Number], Template.[0-Start Date],
Template.[0-End Date], Template.[6-Address Type(1)],
Template.[6-Street(1&2)], Template.[6-Second Addr Line(1&2)],
Template.[6-County Code(1&2)], Template.[6-City(1&2)],
Template.[6-Province(1&2)], Template.[6-Country(1&2)], Template.[6-Postal
Code(1&2)]
FROM Template
ORDER BY Template.[0-Staff Number] DESC;

Query2:
SELECT Template.[0-Staff Number], Template.[0-Start Date], Template.[0-End
Date], Template.[6-Address Type(2)], Template.[6-Street(1&2)],
Template.[6-Second Addr Line(1&2)], Template.[6-County Code(1&2)],
Template.[6-City(1&2)], Template.[6-Province(1&2)],
Template.[6-Country(1&2)], Template.[6-Postal Code(1&2)]
FROM Template
ORDER BY Template.[0-Staff Number] DESC;

But I want to have a query or table that canjoin these queries together.

6-Address Type(1&2) 6-Street(1&2)       6-Second Addr Line(1&2)    6-County
Code(1&2)   6-City(1&2) 6-Province(1&2)     6-Country(1&2)      6-Postal Code(1&2)

Please help. Thanks
--
Many Thanks.

Best regards,
Mary

if you have two queries/tables with union compatible fields (same
type), you can just do something like this

SELECT [Table1].[Field1], [Table1].[Field2], [Table1].[Field3]
FROM [Table1]
WHERE...
ORDER BY...
UNION ALL
SELECT [Table2].[Field8], [Table2].[Field9], [Table2].[Field10]
FROM [Table2]
WHERE...
ORDER BY...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top