Go Back   Access World Forums > Microsoft Access Discussion > Queries

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-16-2019, 07:28 AM   #16
sxschech
Newly Registered User
 
Join Date: Mar 2010
Posts: 608
Thanks: 28
Thanked 111 Times in 100 Posts
sxschech is on a distinguished road
Re: How to filter a Union query?

Another approach is to wrap in () and then the query can behave as a standard select query. It will even show up in the graphical Design View. Of course, you won't be able to edit any contents within a particular SQL making up the union, but the overall Union query can then be treated and edited as a normal select query.

NOTE: Aliasing the overall set of tables as U for Union

Using the example query from these posts:

Code:
SELECT U.ID, U.T, U.N, U.C
FROM (
SELECT Table1.ID, Table1.T, Table1.N, Table1.C
FROM Table1
WHERE TABLE1.T<>'a'
ORDER BY Table1.T DESC
UNION
SELECT Table2.ID, Table2.T, Table2.N, Table2.C
FROM Table2
WHERE Table2.N=20
UNION 
SELECT Table3.ID, Table3.T, Table3.N, Table3.C
FROM Table3) AS U
WHERE U.C > 4
ORDER BY U.C DESC


sxschech is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a multi-select list box to filter a union query (Access 2010) LikeADuck Queries 1 06-22-2016 02:30 AM
Using a union query in conjunction with a filter jjake Queries 1 12-16-2015 05:53 PM
Union query works but will not filter report. Stang70Fastback Queries 3 02-28-2013 06:45 AM
Union query report, parameter prompt? Report filter? Lifeseeker Queries 1 05-12-2011 08:26 PM
filter which queries are used in union query shenty Queries 22 06-29-2009 05:16 AM




All times are GMT -8. The time now is 01:32 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World