Re: how to do 'deep queries'?

From: "Anthony Molinaro" <amolinaro(at)wgen(dot)net>
To: "jeff sacksteder" <jsacksteder(at)gmail(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: how to do 'deep queries'?
Date: 2005-09-27 00:58:40
Message-ID: 3C6C2B281FD3E74C9F7C9D5B1EDA4582182570@wgexch01.wgenhq.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)postgresql(dot)org
[mailto:pgsql-sql-owner(at)postgresql(dot)org] On Behalf Of jeff sacksteder
Sent: Monday, September 26, 2005 8:34 PM
To: pgsql-sql(at)postgresql(dot)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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-09-27 01:03:18 Re: Why doesn't the SERIAL data type automatically have a UNIQUE CONSTRAINT
Previous Message Ferindo Middleton Jr 2005-09-27 00:45:18 Why doesn't the SERIAL data type automatically have a UNIQUE CONSTRAINT