Why use a UNION query (1 Viewer)

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 17:45
Joined
Sep 12, 2006
Messages
15,640
one other thing

modfying union queries can be a bind, if the fields are all specified individually

however, given queryA and query B, you can just say

Code:
select * from QueryA
union
select * from QueryB

you can then edit/modify the source queries more easily, as you can use the QBE grid
 

apr pillai

AWF VIP
Local time
Today, 22:15
Joined
Jan 20, 2005
Messages
735
I use it to prepare P & L Reports for the period up to a particular month.

The month-wise SELECT Queries are prepared and kept for all twelve months. The Report month is selected by the User in a parameter control and based on that the SELECT Queries are assembled from January to the Parameter month into a Union Query and process the Reports.
 

dallr

AWF VIP
Local time
Today, 09:45
Joined
Feb 20, 2008
Messages
81
Sorry I was busy over the last few days and I am now getting some time to add some additional comments.

one other thing,modfying union queries can be a bind, if the fields are all specified individually. However, given queryA and query B, you can just say:

Code:
select * from QueryA
union
select * from QueryB
you can then edit/modify the source queries more easily, as you can use the QBE grid

This can be a very good shortcut approach especially if you are working with many fields. However, one must be careful that the fields are in the same order when using this approach ( Asterisk ) else you can get the wrong set of data within the wrong column. (By the same order I mean the same sequence they are listed in the table’s design view).

The same applies for queries. If you are doing a union on two or more queries the order of the fields in the QBE must be in the same sequence in order to use a UNION with the asterisk and give an accurate representation of the data.

Access is not smart enough to figure out that fields with the same names should really be pulled together in a UNION. It matches the fields in the order which they appear.

Cheers,

Dallr

 

Users who are viewing this thread

Top Bottom