Re: SQL Dilema
Posted in 1996
Michael Eilman (mike@zeus.towson.edu) wrote:
: I am trying to write an SQL Statement to satisy the following situation,
: any help is appreciated.
: Table 1 - People - Teachers and Students
: Table 2 - Student names - exists for teachers only, linked to Table 1 by
: field X
: How do I produce output on a Teacher, his/her students, and Specific
: detail on the students contained in Table 1?
Well, some more information really WOULD be helpful, but I'll take a stab at
it anyway, because I'm just that kind of person ;-)
If I'm interpreting this correctly, you might have something like this:
tab1:
person_id { some way of identifying people }
fname
lname
specific_detail
tab2:
teacher_id { linked to tab1.person_id }
student_id { also linked to tab1.person_id - or maybe you just used
fname/lname here? I'm very fuzzy here. }
If that's the case, something like this should work:
SELECT t1a.fname, t1a.lname, t1b.fname, t1b.lname, t1b.specific_detail
FROM tab1 t1a, tab2, tab1 t1b
WHERE t1a.person_id = tab2.teacher_id
AND t1b.person_id = tab2.student_id
June
---- June Tong Informix Software ----
---- Senior Consultant (415) 926-6140 ----
---- International Support junet@informix.com ----
---- Location-du-jour: Menlo Park, on a break from Beijing ----