multi-table join, final table is outer join count ... - Mailing list pgsql-sql

From The Hermit Hacker
Subject multi-table join, final table is outer join count ...
Date
Msg-id Pine.BSF.4.33.0105121839260.629-100000@mobile.hub.org
Whole thread Raw
Responses Re: multi-table join, final table is outer join count ...  (The Hermit Hacker <scrappy@hub.org>)
List pgsql-sql
Okay, not sure best way to try and describe this ... have multiple tables,
of a form like:

table agid intdata text

table bgid intdata text

table cgid intdata text

table dgid intdata text

I want to return:

a.gid,a.data,b.data,c.data,count(d.data)

where

a.gid = b.gid = c.gid = d.gid

*but* I want count(d.data) to return zero *if* there are no records in
table d ...

essentially, gid has to exist in tables a,b,c but not d ...

So, ignoring table d, i'd have:

SELECT a.gid,a.data,b.data,c.data FROM tablea a, tableb b, tablec cWHERE a.gid = b.gid  AND b.gid = c.gid;

How do I add 'tabled d' to the mix?

Thanks ...

Marc G. Fournier                   ICQ#7615664               IRC Nick: Scrappy
Systems Administrator @ hub.org
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org



pgsql-sql by date:

Previous
From: "Michael Richards"
Date:
Subject: Constraints...
Next
From: The Hermit Hacker
Date:
Subject: Re: multi-table join, final table is outer join count ...