PDA

View Full Version : [HELP] Please, help with a simple SELECT statment


Alex Cosser
07-04-2003, 04:42 AM
> 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


MyLounge.com Site Map
Forum: Cars, Cell Phone, Database, Games, Home Improvement, IT, Music, School, Sports, Web Design, Web Server, Weight Loss

The MyLounge.com forum is intended for informational use only and should not be relied upon and is not a substitute for any advice. The information contained on MyLounge.com are opinions and suggestions of members and is not a representation of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for the accuracy, completeness or usefulness of any postings or the qualifications of any person responding. Please consult a expert or seek the services of an attorney in your area for more accuracy on your specific situation. Please note that our forums also serve as mirrors to Usenet newsgroups. Many posts you see on our forums are made by newsgroup users who may not be members of MyLounge.com Term of Service