Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Is this a bug, or am I loosing it
A more detailed explanation of what is happening:
create table parent( n1 number not null);
create table child(n1 number);
insert into parent values(1);
insert into parent values(2);
insert into child values(1);
commit;
SQL> select * from parent;
N1
1 2
SQL> select * from child;
N1
1
SQL> select * from parent p where p.n1 not in (select c.n1 from child c);
N1
2
SQL> select * from parent p where not exists (select 1 from child c where c.n1 = p.n1);
N1
2
insert into child values(NULL);
SQL> select * from parent p where p.n1 not in (select c.n1 from child c);
no rows selected
SQL> select * from parent p where not exists (select 1 from child c where c.n1 = p.n1);
N1
2
Nothing changes here.
As LS Cheng said "If you have nulls dont use NOT IN!"
At 12:47 PM 2/1/2007, JayDBA wrote:
>I am getting weird results from a NOT IN and NOT EXISTS query. Could
>this be because of NULL's or is it a bug?
Regards
Wolfgang Breitling
Centrex Consulting Corporation
www.centrexcc.com
-- http://www.freelists.org/webpage/oracle-lReceived on Thu Feb 01 2007 - 15:20:49 CST
![]() |
![]() |