Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Intersect with a twist
I have three queries like:
SELECT id FROM a WHERE ... SELECT id FROM b WHERE ... SELECT id FROM c WHERE ...
I want to join these in some way so that I get the id:s that are returned by all three queries.
If I didn't have any more information than that, I would simply do:
SELECT id FROM a WHERE ...
INTERSECT
SELECT id FROM b WHERE ...
INTERSECT
SELECT id FROM c WHERE ...
But the problem is that if a subquery return NO records, that query should be disregarded, so for example if "a" returns 1,2,3, "b" returns 2,3,4 and "c" returns nothing, I want the total query to return 2,3.
I have a sneaking suspicion that I'm missing the obvious answer? Received on Wed Apr 20 2005 - 04:20:17 CDT