combining two queries

RogueUK

New Member
Joined
Mar 31, 2004
Messages
15
I seem to have a problem combining two queries, I only seem to have a limited amount of search criteria I can use.
How can I add two queries and have one single out put?
These are the two queries

SELECT [location codes].[Location Code], [location codes].[ID], [location codes].[Loc Name], [location codes].[Address 1], [location codes].[Post Code]
FROM [location codes]
WHERE ((([location codes].[Location Code])="A0012")) OR ((([location codes].[Location Code])="A0039")) OR ((([location codes].[Location Code])="A0065")) OR ((([location codes].[Location Code])="A0073")) OR ((([location codes].[Location Code])="A0071")) OR ((([location codes].[Location Code])="A0070")) OR ((([location codes].[Location Code])="A0079")) OR ((([location codes].[Location Code])="A0078")) OR ((([location codes].[Location Code])="A0104"));


SELECT [location codes].[Location Code], [location codes].ID, [location codes].[Loc Name], [location codes].[Address 1], [location codes].[Post Code]
FROM [location codes]
WHERE ((([location codes].[Location Code])="B8681" Or ([location codes].[Location Code])="B5517" Or ([location codes].[Location Code])="B5516" Or ([location codes].[Location Code])="B2353" Or ([location codes].[Location Code])="B1905" Or ([location codes].[Location Code])="B1882" Or ([location codes].[Location Code])="A0104"));
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi RogueUK

You can create a UNION query. It is only available in Access, and as long as your headings for both SELECT statements are the same you just add the UNION clause between the SELECT's like so:

Code:
SELECT [location codes].[Location Code], [location codes].[ID], [location codes].[Loc Name], [location codes].[Address 1], [location codes].[Post Code] 
FROM [location codes] 
WHERE ((([location codes].[Location Code])="A0012")) OR ((([location codes].[Location Code])="A0039")) OR ((([location codes].[Location Code])="A0065")) OR ((([location codes].[Location Code])="A0073")) OR ((([location codes].[Location Code])="A0071")) OR ((([location codes].[Location Code])="A0070")) OR ((([location codes].[Location Code])="A0079")) OR ((([location codes].[Location Code])="A0078")) OR ((([location codes].[Location Code])="A0104")); 
UNION
SELECT [location codes].[Location Code], [location codes].ID, [location codes].[Loc Name], [location codes].[Address 1], [location codes].[Post Code] 
FROM [location codes] 
WHERE ((([location codes].[Location Code])="B8681" Or ([location codes].[Location Code])="B5517" Or ([location codes].[Location Code])="B5516" Or ([location codes].[Location Code])="B2353" Or ([location codes].[Location Code])="B1905" Or ([location codes].[Location Code])="B1882" Or ([location codes].[Location Code])="A0104"));

Try that

anvil19
:eek:
 
Upvote 0

Forum statistics

Threads
1,221,692
Messages
6,161,351
Members
451,697
Latest member
pedroDH

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