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 -> UNION of disjoint SELECTs based on other SELECT - how??

UNION of disjoint SELECTs based on other SELECT - how??

From: Anneke Treep <anneke_at_echelon.nl>
Date: Wed, 14 Jul 1999 13:09:59 +0200
Message-ID: <378C7007.FDA284B6@echelon.nl>


Hi all,

I am trying to do the following:
- make a SELECT to get a number of (session.id, person.id, session.type)
tuples;
- depending on the selected session-type, I need to retrieve different
(additional) data;
- finally I have to UNION the resulting selections.

Since the first step is rather a complex query, I would prefer to perform it only once.

How do I do this?

I am hoping something like this pseudo-SQL will be possible:

SELECT (additonal-data)
FROM additional-tables
WHERE (person.person-id, session.session-id, 2) IN (

	    SELECT (session.id, person.id, session.type)
	    FROM   (base-tables)
	    WHERE  (base-restriction)
        ) base_alias

UNION
SELECT (other additional-data)
FROM additional-tables
WHERE (person.person-id, session.session-id, 3) IN

        base_alias
...
more UNIONS like this   

Of course I will take care that the various SELECTs are UNION compatible.

Any suggestions?
And, is it easy to read the person.id, session.id and session-type along with the additional-data?
Many thanks in advance!

Anneke Treep, Echelon BV Received on Wed Jul 14 1999 - 06:09:59 CDT

Original text of this message

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