Re: [HELP] Please, help with a simple SELECT statment

From: Alex Cosser <acosser_at_ford.com>
Date: Fri, 4 Jul 2003 14:42:57 +0200
Message-ID: <be3soi$t4m9_at_eccws12.dearborn.ford.com>


> SELECT * FROM STUDENTS,TUTORS
> WHERE (STUDENTS.Tut_ID=TUTORS.Tut_ID or STUDENTS.Tut_ID
is
> null)

I think this produces a cartesian product on rows where STUDENTS.Tut_ID is null

create table students ( st_id number, tut_id number); insert into students values (1,'');
insert into students values (2,'1');
create table tutors ( tut_id number, tut_name varchar(10)); insert into tutors values (1,'Fred');
insert into tutors values (2,'Joe');
commit;

SQL> SELECT * FROM STUDENTS,TUTORS WHERE STUDENTS.Tut_ID = TUTORS.Tut_ID (+);

     ST_ID TUT_ID TUT_ID TUT_NAME ---------- ---------- ---------- ----------

         2          1          1 Fred
         1

  1 SELECT * FROM STUDENTS,TUTORS
  2* WHERE (STUDENTS.Tut_ID=TUTORS.Tut_ID or STUDENTS.Tut_ID is null) SQL> /      ST_ID TUT_ID TUT_ID TUT_NAME ---------- ---------- ---------- ----------

         1                     1 Fred
         2          1          1 Fred
         1                     2 Joe
Received on Fri Jul 04 2003 - 14:42:57 CEST

Original text of this message