X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 09220D1DD2C for ; Sun, 2 May 2004 13:30:01 -0300 (ADT) 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 40722-06 for ; Sun, 2 May 2004 13:29:40 -0300 (ADT) Received: from msgdirector4.onetel.net.uk (msgdirector4.onetel.net.uk [212.67.96.160]) by svr1.postgresql.org (Postfix) with ESMTP id D6D37D1ECBE for ; Sun, 2 May 2004 13:29:38 -0300 (ADT) Received: from bolek.coachhouse (213-78-117-36.friaco.onetel.net.uk [213.78.117.36]) by msgdirector4.onetel.net.uk (Mirapoint Messaging Server MOS 3.3.6-GR) with ESMTP id BOJ02293; Sun, 2 May 2004 17:29:32 +0100 (BST) Received: (Exim 3.35) #1 (Debian)) protocol: esmtp id 1BKJkd-0002QP-00 ; Sun, 02 May 2004 17:23:35 +0100 Message-ID: <4095207C.8080009@numerixtechnology.de> Date: Sun, 02 May 2004 17:23:24 +0100 From: T E Schmitz Reply-To: mailreg@numerixtechnology.de User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: double left outer join on the same table Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.4 tagged_above=0.0 required=5.0 tests=LINES_OF_YELLING, RCVD_IN_SORBS, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200405/4 X-Sequence-Number: 17718 Hello, I have two tables SECTION and BRAND. SECTION is related to BRAND via two foreign keys. I would like to select ALL SECTIONs whether the FKs are null or not and fetch the BRAND attributes in one SQL statement. In other words I need a double outer join. Is this possible at all? The following doesn't work for two reasons: a) Table name "brand" specified more than once. b) how would I specify the same output columns twice? SELECT SECTION.SECTION_PK, SECTION.SECTION_NAME, SECTION.BRAND_1_FK, SECTION.BRAND_2_FK, BRAND.BRAND_PK, BRAND.BRAND_NAME FROM SECTION left outer join BRAND on BRAND_PK =BRAND_1_FK left outer join BRAND on BRAND_PK =BRAND_2_FK -- Regards, Tarlika Elisabeth Schmitz