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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: NOT IN with NULL-values

RE: NOT IN with NULL-values

From: Larry Elkins <elkinsl_at_flash.net>
Date: Mon, 29 Oct 2001 09:19:14 -0800
Message-ID: <F001.003B7246.20011029090522@fatcity.com>

Frank,

"A NOT IN evaluates to FALSE if *any* member of the set is NULL".

http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/server.817/ a85397/operator.htm#1003933

Also scroll up just a tad on that link and look at the comments for NOT IN in table 3.4. This is a subtlety that many folks overlook until it bites them on the tail.

With regards to your NOT EXISTS, you didn't include correlation between the two tables (which Amar pointed out with the example). Try this:

SQL> select * from fk_ldm1 a
  2 where not exists (select * from fk_ldm2 b where a.id = b.id);

        ID


         3

For each row in fk_ldm1 the sub-query is evaluated. And since you did not include correlation, the sub-query will always return a row(s) (there's no criteria on it), thus making the NOT EXISTS condition FALSE for each row in fk_ldm1.

Regards,

Larry G. Elkins
elkinsl_at_flash.net
214.954.1781

> -----Original Message-----
> From: root_at_fatcity.com [mailto:root_at_fatcity.com]On Behalf Of Kuijten, F.
> (Frank)
> Sent: Monday, October 29, 2001 8:35 AM
> To: Multiple recipients of list ORACLE-L
> Subject: RE: NOT IN with NULL-values
>
>
> Amar,
>
> Thanks.
>
> One question : Do you have a NULL value in the 'am91' table ?
>
> Because that's where my problem is.
> Without the NULL value, all queries are giving the expected results.
>
>
> Greetings,
> Frank
>

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Larry Elkins
  INET: elkinsl_at_flash.net

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Mon Oct 29 2001 - 11:19:14 CST

Original text of this message

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