UNION QUERY

  • Thread starter Thread starter cathy.darnell
  • Start date Start date
C

cathy.darnell

Hello,
I'd like to do a union query, can you give me an example or two?
My project is to pull data from several tables which are all the same
structure they just all have different data in the fields..
Thanks for any help you can give.
Cathy
 
If you want to include all fields from a series of identically structured
tables/queries, you can use this syntax:

TABLE [qryHourlyTC-Advertising]
UNION TABLE [qryHourlyTC-CashOverShort]
UNION TABLE [qryHourlyTC-MiscControllable]
UNION TABLE [qryHourlyTC-MiscNonControllable]
UNION TABLE [qryHourlyTC-ProductLiability];

If you want/need to specify specific fields:
SELECT SimulationDescription, [Emp Type], Instance, HalfHour, ProcessID,
ActivityID, Duration
FROM datTaskLogOutput
UNION SELECT SimulationDescription, [Emp Type], Instance, HalfHour,
ProcessID, ActivityID, IdleTime
FROM qryTaskOutputSTEmpIdleByHHhh
ORDER BY SimulationDescription, [Emp Type], Instance, HalfHour;

If a field (or placeholder) doesn't actually exist in a given table, you can
specify an empty Alias as placeholder: "...Null As [Emp Type]..."

HTH,
 
Back
Top