Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 021824770B2 for ; Wed, 15 Jan 2003 09:42:32 -0500 (EST) Received: from ns.aprote.ee (ns.aprote.ee [80.235.78.106]) by postgresql.org (Postfix) with ESMTP id BE181476371 for ; Wed, 15 Jan 2003 09:40:28 -0500 (EST) Received: Message by Barricade ns.aprote.ee with ESMTP id h0FEmjB29147 for ; Wed, 15 Jan 2003 16:48:45 +0200 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Re: Oracle outer join porting question X-MIMEOLE: Produced By Microsoft Exchange V6.0.5762.3 Date: Wed, 15 Jan 2003 16:40:32 +0200 Message-ID: <81132473206F3A46A72BD6116E1A06AE3EC030@black.aprote.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] Oracle outer join porting question Thread-Index: AcK8ospeWQbn6EG1SO2GW3LnogfynAAAQdAQ From: "Tambet Matiisen" To: "Marko Asplund" , X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/214 X-Sequence-Number: 11079 > -----Original Message----- > From: Marko Asplund [mailto:aspa@kronodoc.fi] > Sent: Wednesday, January 15, 2003 4:31 PM > To: pgsql-sql@postgresql.org > Subject: [SQL] Oracle outer join porting question >=20 >=20 >=20 > i'm trying to port an existing application from Oracle8i to=20 > PostgreSQL but > i'm having problems understanding a certain outer join query=20 > type used in > the application. the query includes a normal outer join=20 > between two tables > but also uses outer join syntax to join a table with a=20 > constant. here's a > simplified version of the query: >=20 > SELECT doc.id,doc.title,sub.user_id,sub.operation > FROM document doc, document_subscription sub > WHERE 6 =3D sub.user_id(+) AND sub.document_id(+) =3D doc.id; >=20 > what does the '6 =3D sub.user_id(+)' condition exactly do in=20 > this query?=20=20 > how would this be translated SQL92 join syntax used by PostgreSQL? >=20 > i've tried converting it to: >=20 > SELECT doc.id,doc.title,sub.user_id,sub.operation > FROM document doc LEFT OUTER JOIN document_subscription sub > ON sub.document_id =3D doc.id > WHERE (sub.user_id =3D 6 OR sub.user_id IS NULL); >=20 > but this query is missing the rows in the documents table which have a > corresponding document_subscription row with 'not user_id =3D 6'. >=20 Try this: SELECT doc.id,doc.title,sub.user_id,sub.operation FROM document doc LEFT OUTER JOIN document_subscription sub ON sub.document_id =3D doc.id AND sub.user_id =3D 6;=20 Tambet