Re: Simplyfying many equals in a join

From: <btober(at)seaworthysys(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Simplyfying many equals in a join
Date: 2004-02-26 13:25:01
Message-ID: 64666.216.238.112.88.1077801901.squirrel@$HOSTNAME
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Karel Zak 2004-02-26 13:35:33 ORDER BY different locales
Previous Message Randall Skelton 2004-02-26 13:19:31 Re: Simplyfying many equals in a join