Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 5B50E63261E for ; Fri, 12 Feb 2010 08:17:53 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 48732-03 for ; Fri, 12 Feb 2010 12:17:39 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from jupiter.marktest.pt (delta.marktest.pt [80.251.174.116]) by mail.postgresql.org (Postfix) with ESMTP id F1695632563 for ; Fri, 12 Feb 2010 08:17:37 -0400 (AST) Received: from Proteu (proteu.marktest.pt [10.61.90.54]) by jupiter.marktest.pt with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id Z83S9H6Y; Fri, 12 Feb 2010 12:17:36 -0000 Message-ID: <723CFC801B0846B9B31DCE45B62222FA@marktestcr.marktest.pt> From: "Oliveiros C," To: "Louis-David Mitterrand" , References: <20100212111453.GA16318@apartia.fr> <34E07A4C4CDA4FFCB56CD63C675568ED@marktestcr.marktest.pt> <20100212115747.GA21659@apartia.fr> Subject: Re: "left join" not working? Date: Fri, 12 Feb 2010 12:17:35 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.002 tagged_above=-10 required=5 tests=BAYES_50=0.001, STOX_REPLY_TYPE=0.001 X-Spam-Level: X-Archive-Number: 201002/47 X-Sequence-Number: 33646 Yes, because your WHERE is something that comes after the operation of the LEFT JOIN, in practice, defeating the purpose you intented. On your second query the p.id_line = 1 doesn't do that because it is part of the LEFT JOIN itself.. HTH Best, Oliveiros d'Azevedo Cristina ----- Original Message ----- From: "Louis-David Mitterrand" To: Sent: Friday, February 12, 2010 11:57 AM Subject: Re: [SQL] "left join" not working? > On Fri, Feb 12, 2010 at 11:35:02AM -0000, Oliveiros C, wrote: >> My first guess is that >> NULL fails the condition on your WHERE clause, >> p.id_line = 1 >> >> So your WHERE clause introduces an additional level of filtering >> that filters out the NULLs coming from the LEFT JOIN... > > So, if I understand correctly, a WHERE filters all results regardless of > join conditions and can turn an OUTER JOIN into an INNER JOIN. > > Thanks for pointing that out! > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql >