Union query

  • Thread starter Thread starter Nick Read
  • Start date Start date
N

Nick Read

How can I create a union query for two queries in which I
want to include all the columns.
 
Go to the database window - query tab and click on New. Select Design View
and click OK. In the Show Table dialog, click Close. Click the SQL button at
the far left of the toolbar at the top of the screen. You will be in SQL
view where you can type in the union query:
Select .......
Union
Select .....;

Esentially you have two SQL strings joined by the word Union. No semicolon
at the end of the first SQL string.
 
How can I create a union query for two queries in which I
want to include all the columns.

If the two queries have the same number of fields, and if they match
pairwise in size and datatype, then open the SQL window of a new
query. Don't select ANY tables or queries, just create a new query and
select SQL from the leftmost toolbar.

Replace the default

SELECT;

with

SELECT * FROM firstqueryname
UNION
SELECT * FROM secondqueryname

Use "UNION ALL" instead of "UNION" if you want to see all records in
both queries; the UNION alone will remove any duplicate records. UNION
ALL is faster if you're not expecting there to be any dups.

John W. Vinson[MVP]
 
Back
Top