sql question
Posted in 1999
Topics: Triggers, Constraints & Referential Integrity
hey guys, could someone help me out in doing the following sql? table a: autonumber k1 (primary key) interger policyid fld1, fld2, fld3 ... table b: autonumber k2 (primary key) interger a_id ( foreign key to k1 in table a) fld1, fld2, fld3 table c: autonumber k3 (prmary key) interger b_id (foreign key to k2 in table b) fld1, fld2, fld3 Now I want to construct a sql whose output would be all table c record whose correspoding table a record 's policyid is "123" for example. basically, c is related to b, b is related to a, the critiera is on a. thanks a lot guys. yan
Try this:
select * from c, b, a
where c.b_id=b.k2
and b.a_id=a.k1
and a.k1="123"
Yan Zhu wrote in message <7b3pef$fn5$1@news.xmission.com>...
>
>
> hey guys, could someone help me out in doing the following sql?
>
> table a:
> autonumber k1 (primary key)
> interger policyid
> fld1, fld2, fld3 ...
>
> table b:
> autonumber k2 (primary key)
> interger a_id ( foreign key to k1 in table a)
> fld1, fld2, fld3
>
> table c:
> autonumber k3 (prmary key)
> interger b_id (foreign key to k2 in table b)
> fld1, fld2, fld3
>
>
> Now I want to construct a sql whose output would be all table c
>record whose correspoding table a record 's policyid is "123" for
>example.
>
> basically, c is related to b, b is related to a, the critiera is on
>a.
>
> thanks a lot guys.
>
>yan
>
>
>
>
>
>
On my way home from work I realized you are going to get far too much
information if you don't specify which data you want returned from the
select statement. It should read:
select c.k3, c.b_id, c.fld1, c.fld2 (and so on) from c, b, a where ...
John-Thomas Richards wrote:
>
> Try this:
>
> select * from c, b, a
> where c.b_id=b.k2
> and b.a_id=a.k1
> and a.k1="123">
> Yan Zhu wrote in message <7b3pef$fn5$1@news.xmission.com>...
> >
> >
> > hey guys, could someone help me out in doing the following sql?
> >
> > table a:
> > autonumber k1 (primary key)
> > interger policyid
> > fld1, fld2, fld3 ...
> >
> > table b:
> > autonumber k2 (primary key)
> > interger a_id ( foreign key to k1 in table a)
> > fld1, fld2, fld3
> >
> > table c:
> > autonumber k3 (prmary key)
> > interger b_id (foreign key to k2 in table b)
> > fld1, fld2, fld3
> >
> >
> > Now I want to construct a sql whose output would be all table c
> >record whose correspoding table a record 's policyid is "123" for
> >example.
> >
> > basically, c is related to b, b is related to a, the critiera is on
> >a.
> >
> > thanks a lot guys.
> >
> >yan
> >
> >
> >
> >
> >
> >