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

Home -> Community -> Usenet -> c.d.o.server -> SQL Newbie wants to select data from 3 tables

SQL Newbie wants to select data from 3 tables

From: <antonyliu2002_at_yahoo.com>
Date: 23 Jun 2006 15:00:15 -0700
Message-ID: <1151100015.868879.178780@r2g2000cwb.googlegroups.com>


I am very very new to SQL. I want to get student information from 3 tables T1, T2, T3 in an Oracle database.

I tried this:

select T1.ID, T1.Fname, T1.Lname, T2.StudentType, T2.StudentMajor, T3.PreviousCollege
from T1, T2, T3
where T1.ID = 123 and T2.ID=123 and T3.ID=123

This works fine if ID 123 has a record in each of the three tables.

I get 0 row if student ID 123 has records in both T1 and T2, but does not have a record in T3. In other words, if student ID 123 has not attended any previous college.

I want to get one row of info about this student ID even if he/she does not have any record in T3. That is, in this case, I want to get things like below:

Fname Lname StudentType StudentMajor PreviousCollege John Doe Freshman Accounting

Why doesn't my sql do this for me?

Thanks Received on Fri Jun 23 2006 - 17:00:15 CDT

Original text of this message

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