Re: How to: SQL Query with multiple FK relations to single table

From: Carl <carl.stottlemyer_at_lmco.com>
Date: 26 Sep 2002 15:10:48 -0700
Message-ID: <bc814416.0209261410.37e7fa8d_at_posting.google.com>


Thank you. I figured it was easy. Not for 'homework' though.

postbus_at_sybrandb.demon.nl (Sybrand Bakker) wrote in message news:<a20d28ee.0209260017.33d99c42_at_posting.google.com>...
> carl.stottlemyer_at_lmco.com (Carl) wrote in message news:<bc814416.0209250544.5ffe57d3_at_posting.google.com>...
> > The following example seems like it should be simple but it is
> > stumping me. How would you construct a SQL query that prints out the
> > name (referenced in the People table) of the father and son identified
> > in the fathers table.
> >
> > Table People
> > ------------
> > pplNo
> > pplName
> >
> > Table Fathers
> > -------------
> > fatherNo (references People.pplNo)
> > sonNo (references People.pplNo)
> >
> > Thanks,
> > Carl
>
>
> By joining the people table 2 times with fathers
>
> select f.pplname, s.pplname
> from fathers, people f, people s
> where s.peopleno = fathers.sonno
> and f.peopleno = fathers.fatherno
>
> This is a question of the 'homework' type though.
>
> Hth
>
> Sybrand Bakker
> Senior Oracle DBA
Received on Fri Sep 27 2002 - 00:10:48 CEST

Original text of this message