X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B8A8D4758F1 for ; Mon, 24 Mar 2003 10:18:14 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 12D16474E44 for ; Mon, 24 Mar 2003 10:18:14 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2OFIAub012786; Mon, 24 Mar 2003 10:18:11 -0500 (EST) To: "Correia, Carla" Cc: "'pgsql-sql@postgresql.org'" Subject: Re: Complex outer joins? In-reply-to: <0F232CC93A58D6119C1600B0D0799B8102338822@hamsrvmx03.logica.co.uk> References: <0F232CC93A58D6119C1600B0D0799B8102338822@hamsrvmx03.logica.co.uk> Comments: In-reply-to "Correia, Carla" message dated "Mon, 24 Mar 2003 10:49:53 +0000" Date: Mon, 24 Mar 2003 10:18:10 -0500 Message-ID: <12785.1048519090@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-31.9 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,UPPERCASE_25_50 autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/548 X-Sequence-Number: 12586 "Correia, Carla" writes: > Simplified example: > select G.SELID, G.TEXT, > L.ID as SELLEVELID , L.SELLEVEL, L.LEVELJOIN, L.LEVELTEXT, > C.ID as KRITERIENFELDID, C.SELFLD > from G, L, C > where > and G.SELID = L.SELID (+) > and L.SELID = C.SELID (+) > and L.SELLEVEL = C.SELLEVEL (+) > How can i write this in Postgres? One of the un-fun things about Oracle's nonstandard syntax is that you can't easily tell what the join order is supposed to be. (At least I can't; anyone know how this will get interpreted?) The SQL-standard way of writing this would presumably be either from G left join L on (G.SELID = L.SELID) left join C on (L.SELID = C.SELID and L.SELLEVEL = C.SELLEVEL) or from G left join (L left join C on (L.SELID = C.SELID and L.SELLEVEL = C.SELLEVEL)) on (G.SELID = L.SELID) depending on which join you think ought to be done first. It might be that the results are the same in this case, but I'm not convinced of that. In general the results of outer joins definitely depend on join order. regards, tom lane