cross-table reference

From: "Mukesh Ghatiya" <mukeshg(at)juniper(dot)net>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: cross-table reference
Date: 2005-06-22 09:26:08
Message-ID: 36586775D676C443A856A00683526649A0C797@gaugeboson.jnpr.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I need to perform a query similar to

SELECT table1.a.b.x table1.a.c.x from table1;

In this case "a" is an attribute in 'table1' and is a foreign key to
other table2 which has 'b', and 'c' as attributes, which again are
foreign keys to table3.

Is there any simple way of doing this other than using the complicated
nested joins which would include aliases also.

SELECT table31.x table32.x
FROM table1, table3 AS table31, table3 AS table32
WHERE table1.a = table2.id
AND table2.b = table31.id
AND table2.c = table32.id

Thanks,
Mukesh

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Veikko Mäkinen 2005-06-22 11:27:46 Alias to a type
Previous Message Sim Zacks 2005-06-22 08:22:04 Re: scroll cursor bug or me?