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 -> Re: New-Bie SQL Question...

Re: New-Bie SQL Question...

From: James Lorenzen <lorenzen_at_tiny.net>
Date: 1998/05/08
Message-ID: <lorenzen-ya02408000R0705982204070001@news.visi.com>#1/1

In article <6isqc6$7fv$1_at_engnews2.Eng.Sun.COM>, gosar_at_EBB.Eng.Sun.COM wrote:

>Hi,
>
>I have 2 tables (similar with 10 fields each...)
>each one has around 500K Rows with the second one
>having 100 Rows extra....
>
>How do I find the 100 Rows which are extra in the 2nd table
>using one SQL...??
>
>TIA,
>Bg

Is there a unique key that is common between the two tables? If so, you can use an outer join and a where clause to target the "holes".

SELECT a_key from a, b WHERE a_key = b_key (+) AND b_key IS NULL ; This works where a is the larger table.

Another option is the "minus" operator. IE

SELECT * from A
MINUS SELECT * from B

The performance will vary depending on indexes that may or may not be present.

HTH
   James

-- 
lorenzen_at_tiny.net             | Life is complex; it has
                              |   real and imaginary parts
Received on Fri May 08 1998 - 00:00:00 CDT

Original text of this message

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