Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Intersect with a twist

Intersect with a twist

From: Dagger <windydaggers_at_hotmail.com>
Date: 20 Apr 2005 02:20:17 -0700
Message-ID: <1113988817.279324.144040@o13g2000cwo.googlegroups.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US