Re: Help with SQL Syntax

From: Rick Perro <Frederick_Perro_at_zap.ems.cdc.com>
Date: 7 Dec 92 15:15:16 GMT
Message-ID: <Frederick_Perro-071292091326_at_rperro180.ems.cdc.com>


In article <1992Dec4.202332.21512_at_cbfsb.cb.att.com>, gerette_at_cbnewsb.cb.att.com (marianne.g.pittorino) wrote:

  • stuff deleted-

> I need an SQL statement that will select the rows in FIRST that do not
> match any row in SECOND (and vice versa). For example, let's pretend we have
> the following data:
> FIRST SECOND
> ----- ------
> 1111 1111
> 2222 2222
> 3333 4444
> 5555 5555
>
> I need to know that 3333 exists in FIRST but not in SECOND, and that 4444
> exists in SECOND but not in FIRST. I do not need to know this in the same
> SQL statement.

One way to do it is to use an outer join and look for null columns. The SQL statement for selecting rows from FIRST that donUt exist in SECOND would be:

SELECT FIRST.COLUMN1 FROM FIRST, SECOND WHERE FIRST.COLUMN1 = SECOND.COLUMN1(+) AND
SECOND.COLUMN1 IS NULL;



Rick Perro
Frederick_Perro_at_zap.ems.cdc.com

All opinions expressed are my own. Received on Mon Dec 07 1992 - 16:15:16 CET

Original text of this message