X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 22328D1B44A for ; Sat, 17 Jan 2004 02:37:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 43202-03 for ; Fri, 16 Jan 2004 22:37:08 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 95C73D1B4A1 for ; Fri, 16 Jan 2004 22:37:04 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i0H2anU6028169 for ; Sat, 17 Jan 2004 02:36:49 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i0H2TvS1019544 for pgsql-sql@postgresql.org; Sat, 17 Jan 2004 02:29:57 GMT From: Colin Fox Organization: CF Consulting Inc. Subject: Left joins with multiple tables User-Agent: Pan/0.14.0 (I'm Being Nibbled to Death by Cats!) Message-Id: X-Newsgroups: comp.databases.postgresql.sql MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8bit Lines: 30 Date: Sat, 17 Jan 2004 02:30:01 GMT To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/143 X-Sequence-Number: 16536 Hi, all. I've got a bit of a problem here. I have 4 tables - people, a, b, c (not the original names). For each person in the people table, they may or may not have a record in a, may or may not have a record in b, and may or may not have a record in c. Handling the first table (a) is easy: select id, name from people p left outer join a on a.person_id = p id; But I'd like to be able to do something like: select id, name, a.field1, b.field2, c.field3 from people p left outer join a on a.person_id = p id, people p left outer join b on b.person_id = p.id, people p left outer join c on c.person_id = p.id; Naturally you can't repeat the 'people p' clause 3 times, but is there some other syntax that would let me do this? Thanks! cf