Re: Simplyfying many equals in a join - Mailing list pgsql-general

From
Subject Re: Simplyfying many equals in a join
Date
Msg-id 64666.216.238.112.88.1077801901.squirrel@$HOSTNAME
Whole thread Raw
In response to Re: Simplyfying many equals in a join  ("cnliou" <cnliou@so-net.net.tw>)
List pgsql-general
>>Is there a shorthand notation when performing a multi-table join and

What's the difference between a "multi-table join" and a "join"?

>> one column is to be equaled in all tables?
>
> Is this you are looking for?
>
> SELECT t1.c7,t2.c6
> FROM t1,t2
> USING (c1,c2,c3)
> WHERE t1.c4='2004-2-28' AND t2.c5='xyz'
>
> performs the same as
>
> SELECT t1.c7,t2.c6
> FROM t1,t2
> WHERE t1.c1=t2.c1 and t1.c2=t2.c2 and t1.c3=t2.c3
> and t1.c4='2004-2-28' AND t2.c5='xyz'
>
> CN
>

I think this should work, too:

SELECT t1.c7,t2.c6
FROM t1,t2
WHERE (t1.c1, t1.c2, t1.c3, t1.c4, t2.c5)= (t2.c1, t2.c2, t2.c3,
'2004-2-28', 'xyz')




~Berend Tober




pgsql-general by date:

Previous
From: "Ben"
Date:
Subject: Simple, but VERYuseful enhancement for psql command - or am I missing something?
Next
From: "Karl O. Pinc"
Date:
Subject: Re: Moving from MySQL to PGSQL....some questions