Query on Multiple Queries

psycoperl

Active Member
Joined
Oct 23, 2007
Messages
338
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
  3. Web
Hi folks,
I am using MS ACCESS to query a MS EXCEL spreadsheet.

I have 6 queries on the the spreadsheet that return the same fields, I would like to know if it is possible and how to write 1 query that will combine all the UNIQUE results so that I can create a Mail Merge in MS WORD.

All the queries return

Phase, Type, Student ID, First Name, Last Name, Address, City, State, Zip Code, Test(s) Needed, TestDate, TestTime

Thanks for your assistance.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
You can do that with a UNION query, which needs to be built in SQL. Do the following:

1. Open each of the 6 queries and switch to SQL view. Query1 ... Query6
2. Create a new, blank query and switch to SQL view. This will be the UNION query.
3. Copy all of the SQL from Query1 and replace the SELECT word in the UNION query. Remove the final semi-colon
In the next blank line, type UNION
4. Now, copy the SQL from Query2 and paste it below the UNION row. Remove the semi-colon, go to the nect blank line, type UNION.
Repeat step 4 for Query3 ... Query6

You should end up with
SQL from Query1
UNION
SQL from Query2
UNION
SQL from Query3
UNION
SQL from Query4
UNION
SQL from Query5
UNION
SQL from Query6

Save the query and run it.

Denis
 
Upvote 0
if the 6 queries are against the same table it's possible that you need to write your query in such a way to get all the records you need rather than distributing it out over 6 queries and then unioning them all back together in a seventh.
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,472
Members
449,087
Latest member
RExcelSearch

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top