Union Query

  • Thread starter Thread starter DES
  • Start date Start date
From the queries tab in the database window, click new. Close the
tables/queries dialog. Select SQL view and write the code. You can get info
on the syntax by using VBA Help.
In the Table of Contents, clock on Microsoft Jet SQL Reference
Click on Data Manipulation Language
Click on UNION Operation
 
DES said:
How do I go about creating a union query?

Assuming this post stems from your prior post, You received some very
good advice. Your design is faulty. You need to redesign your DB.
All of this info should be in ONE table. See George's post in your
other thread.

gls858
 
Easiest way is to create a select query in the standard method and then
switch to the SQL view from the design view. You should see something like

SELECT AField, BField, CField
FROM SomeTable
WHERE AField = "xxx";

Delete the semicolon
Type UNION ALL

NOW type in the query for the second table

SELECT AField, BField, CField
FROM SomeTable
WHERE AField = "xxx"

UNION ALL

SELECT DField, EField, FField
FROM SomeOtherTable
WHERE AField = "xxx"

Each query in the UNION must have the same number of fields and the field
types must be alike. So in the sample AField and DField must both be text
fields. If BField is a date field then EField must be a date field. If
CField is a number field then FField must be a number field.


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Back
Top