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

Home -> Community -> Usenet -> c.d.o.server -> Re: better way

Re: better way

From: Gary Gapinski <glg_at_apk.net>
Date: Wed, 17 Oct 2001 05:58:08 -0400
Message-ID: <3BCD5630.831B9BC5@apk.net>


If you re-think this as

"get the union of resultset1 and resultset2"

then you can just leave off the "not in ... resultset1" predicate on resultset2.

If you actually wish resultset1 to be delivered prior to resultset2 in the union result set, add a column to each so that the union resultset can be subjected to an ORDER BY clause on that column.

sweidanz_at_yahoo.com wrote:
>
> Is there a better way of doing the following query:
>
> "first get all the records in resultset1 and then get records in
> resultset2 where the records are not in resultset1"
>
> other than
>
> SELECT blah blah...
> FROM resultset1
> WHERE blah blah...
>
> UNION
>
> SELECTblah blah...
> FROM resultset2
> WHERE keycolumns not in (SELECT keycolumns...
> FROM resultset1
> WHERE blah blah...)
>
> having that the query for resultset1 is really very big and will take
> quite too much time, i dont think its a good idea to run it again as a
> subquery.
>
> Any one has got other suggested way of doing it?
>
> thanks,
> ZS
Received on Wed Oct 17 2001 - 04:58:08 CDT

Original text of this message

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