Re: How to list parent's table's attribute via sql without function or trigger?

From: Brian E Dick <bdick_at_cox.net>
Date: Sat, 25 Jan 2003 21:29:40 GMT
Message-ID: <8lDY9.21862$GX4.839107_at_news2.east.cox.net>


What is the result of the following query?

select id1, id2, count(*)
from t1
group by id1, id2
having count(*) > 1

"John" <johnwu_at_yorku.ca> wrote in message news:1673c1fd.0301251110.7454523_at_posting.google.com...
> Suppose the relationship as
>
> table t1,t2,t3,t4
>
> t1(ID1 integer,ID2 char) fk ID1 -> t2,fk ID2 ->t4
> t2(ID1 integer,category char) fk category ->t3
> t3(category char,beer double,pork double)
> t4(ID2 char,discount double,total double)
>
> what listing from t1'data as
>
> ID1 beer pork ID2 discount total
> .....
> .....
>
>
> Can any one tell me how to use pure sql without creating any
> function/view/trigger... to accomplish it?
>
> I've tried
> select t1.ID1,t3.beer,t3.pork,t1.ID2,t4.discount,t4.total
> from t1,t2,t3,t4
> where
> t1.id1=t2.id1 and
> t2.category=t3.category and
> t1.id2=t4.id2
>
> but it listed lots and lots duplicated rows.
>
> Thanks lots in advance.
>
> --
> John
> Toronto
Received on Sat Jan 25 2003 - 22:29:40 CET

Original text of this message