X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 70CA3310044 for ; Sat, 28 Jun 2003 06:16:30 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 28482-07 for ; Sat, 28 Jun 2003 03:16:19 -0300 (ADT) Received: from web80510.mail.yahoo.com (web80510.mail.yahoo.com [66.218.79.80]) by svr1.postgresql.org (Postfix) with SMTP id 3311030FF93 for ; Sat, 28 Jun 2003 03:16:19 -0300 (ADT) Message-ID: <20030628061618.19440.qmail@web80510.mail.yahoo.com> Received: from [203.131.94.141] by web80510.mail.yahoo.com via HTTP; Fri, 27 Jun 2003 23:16:18 PDT Date: Fri, 27 Jun 2003 23:16:18 -0700 (PDT) From: Ludwig Lim Subject: Re: Question on OUTER JOINS. To: Tom Lane Cc: PostgreSQL Mailing List In-Reply-To: <16131.1056780183@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200306/327 X-Sequence-Number: 14085 --- Tom Lane wrote: > Ludwig Lim writes: > > 1) Is the ON clause of an OUTER JOIN always > > evaluated first before the WHERE clause? > > No; the planner will do whatever it thinks is the > most efficient way > (assuming it can prove that the reordering it wants > to do won't change > the query result). If re-ordering does change the result, is the ON clause evaluated first and the WHERE filters out the result of the OUTER JOIN? > > Is there a way to rewrite the query as a view > such > > that one can do: > > I'm really not clear on what you want here. Better > example please? > Sorry for not making it that clear. Is there way of rewritting : SELECT a.status, employee_id FROM permission a LEFT JOIN ( SELECT * FROM employee WHERE employee_id =5) as b ON (a.status = b.status) WHERE status='test' into a query that has no subselect in the FROM clause. I mean can the query above be rewritten into something like: SELECT a.status, b.employee_id FROM permission a LEFT JOIN employee b ON (a.status = b.status) WHERE a.status = 'test' and b.employee_id = 5; Thank you very much, ludwig __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com