X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 210834764DF for ; Wed, 23 Apr 2003 14:00:38 -0400 (EDT) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by postgresql.org (Postfix) with ESMTP id 26FAE476344 for ; Wed, 23 Apr 2003 13:55:33 -0400 (EDT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-35.mail.demon.net with esmtp (Exim 3.36 #2) id 198OSv-0006Lz-0Z; Wed, 23 Apr 2003 18:55:32 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 58F91161D7; Wed, 23 Apr 2003 18:55:17 +0100 (BST) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id A0C3D15A64; Wed, 23 Apr 2003 18:55:16 +0100 (BST) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: "Marco Roda" , Subject: Re: OUTER JOIN Date: Wed, 23 Apr 2003 18:55:36 +0100 User-Agent: KMail/1.4.3 References: <000401c304ec$a77547e0$0301a8c0@amdosoft.local> In-Reply-To: <000401c304ec$a77547e0$0301a8c0@amdosoft.local> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304231855.37050.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Spam-Status: No, hits=-38.9 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/343 X-Sequence-Number: 13044 On Thursday 17 Apr 2003 3:21 pm, Marco Roda wrote: > Hallo, > > I need to port some SQL from Oracle to PostgreSQL v7.2, but I am finding > problems with outer joins. [snip] > and here is the SQL for Oracle: > SELECT ST.id, ST.order_num, ST.from_time, ST.to_time, ST.disabled, > SD.description > FROM shift_type ST, shift_desc SD > WHERE ST.id =3D SD.shift_type_id(+) AND SD.app_language_id(+) =3D 2 > ORDER BY ST.order_num > > The expected result should be: > id | order_num | from_time | to_time | disabled | description > ----+-----------+-----------+----------+----------+------------- > 1 | 1 | 06:00:00 | 14:00:00 | f | > 2 | 2 | 14:00:00 | 22:00:00 | f | > 3 | 3 | 22:00:00 | 06:00:00 | t | > 6 | 6 | 00:00:00 | 23:00:00 | f | SHIFT_DE > with description populated with NULL, as app_language_id not found. > > It seems that Oracle's outer joins work on the basis the single record, > while PostgreSQL don't. > How to do it? SELECT ST.id, ST.order_num, ST.from_time, ST.to_time, ST.disabled,=20 SD.description FROM shift_type ST LEFT JOIN shift_desc SD=20 ON ST.id=3DSD.shift_type_id AND SD.app_language_id=3D2 ORDER BY ST.order_num; That seems to work. Out of curiosity, what were you trying? --=20 Richard Huxton