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: join query question

Re: join query question

From: john sprague <bearpig_at_attglobal.net>
Date: Thu, 21 Jun 2001 21:55:07 -0500
Message-ID: <3B32B38B.92D3442A@attglobal.net>

select

    *
from

    tablea,
(select empnum

    from table a
 minus

    select empnum
    from table b) indexer
where
indexer.empnum = tablea.empnum

The 'where not exists ' statement earlier can have detrimental connotations. Try to avoid negation and base the seed on what is hopefully an indexed column ( empnum) in both source tables.

If I am wrong - I hope someone out there will bat me. These positive seeds have generally worked better for me than negations. Oracle does minus evaluations nicely on index columns.

jds

Brian Tkatch wrote:

> On Thu, 21 Jun 2001 15:37:19 GMT, vk02720 <nospam_at_newsranger.com>
> wrote:
>
> >table A and table B both have a common field empnum.
> >What is the most optimal query to get the data from table A which is not in the
> >table B using empnum ?
> >
> >TIA
>
> I would assume
>
> SELECT * FROM Table_A WHERE NOT EXISTS
> (SELECT * FROM Table_B WHERE Empnum = Table_A.Empnum);
  Received on Thu Jun 21 2001 - 21:55:07 CDT

Original text of this message

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