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,
 

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

Similar Threads

Union query 5
Union Query with division 2
Union Query 2
Union Query and Field Alias 7
Union Query 7
Union query not working with * 3
Query is too complex 5
Union query, combine all 4 fields into 1 field 5

Back
Top