X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 643A1528AD for ; Wed, 17 Aug 2005 13:51:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52509-05 for ; Wed, 17 Aug 2005 16:51:30 +0000 (GMT) Received: from TWMAIL.ESNCC.COM (static-66-173-159-28.t1.cavtel.net [66.173.159.28]) by svr1.postgresql.org (Postfix) with ESMTP id 044DD52859 for ; Wed, 17 Aug 2005 13:51:20 -0300 (ADT) Received: from spawar2i8uvlb9 ([150.125.117.63]) by TWMAIL.ESNCC.COM with Microsoft SMTPSVC(5.0.2195.6713); Wed, 17 Aug 2005 12:51:19 -0400 From: "Lane Van Ingen" To: Subject: Is it This Join Condition Do-Able? Date: Wed, 17 Aug 2005 12:54:50 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181 Importance: Normal X-OriginalArrivalTime: 17 Aug 2005 16:51:19.0888 (UTC) FILETIME=[E4599D00:01C5A34B] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.343 required=5 tests=[AWL=-0.293, FORGED_RCVD_HELO=0.05, HOT_NASTY=0.586] X-Spam-Level: X-Archive-Number: 200508/123 X-Sequence-Number: 22351 Given three tables: a, b, c ; each consist of a 'keyfld' and a field called 'foo': tbl a tbl b tbl c --------- --------- --------- a.keyfld b.keyfld c.keyfld a.foo1 b.foo2 c.foo3 I want to always return all of tbl a; and I want to return b.foo2 and c.foo3 if they can be joined to based on keyfld.a; I know that it will involve a LEFT OUTER JOIN on table a, but have not seen any examples of joins like this on 3 or more tables. select a.keyfld, a.foo1, b.foo2, c.foo3 from a, b, c where a.keyfld = and a.keyfld = b.keyfld and a.keyfld = c.keyfld; Results could look like this: a.keyfld a.foo1 b.foo2 c.foo3 xxxx xxxx xxxx (null) xxxx xxxx (null) xxxx xxxx xxxx (null) (null) xxxx xxxx xxxx xxxx