that query is 100% correct.
it’s just an equijoin (a type of inner join) between 3 tables.
the syntax you show is how queries should be written and is more
representative of what a joins between relations really are:
Cartesian products with filters applied
the ansi syntax, the explicit JOIN … ON stuff is (imho) unnecessary,
useful only for outer joins since all the vendors did it differently.
what you have will work for postgreSQL, I used the syntax you show in my book
for every single join recipe except for outjoins.
are you seeing errors?
regards,
Anthony
-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of jeff sacksteder
Sent: Monday, September 26, 2005 8:34 PM
To: pgsql-sql@postgresql.org
Subject: [SQL] how to do 'deep queries'?
Is there supported syntax to do 'deep' queries? That is where A relates to B relates to C, returning fields from each table?
This doesn't seem to work. Is there a google-able term for this sort of query?
select
foo.aaa,
bar.bbb,
baz.ccc
from
foo,bar,baz
where
foo.bar_id = bar.id
and
bar.baz_id = baz.id