Re: "left join" not working?

From: "Oliveiros C," <oliveiros(dot)cristina(at)marktest(dot)pt>
To: "Louis-David Mitterrand" <vindex+lists-pgsql-sql(at)apartia(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: "left join" not working?
Date: 2010-02-12 12:17:35
Message-ID: 723CFC801B0846B9B31DCE45B62222FA@marktestcr.marktest.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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" <vindex+lists-pgsql-sql(at)apartia(dot)org>
To: <pgsql-sql(at)postgresql(dot)org>
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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Louis-David Mitterrand 2010-02-12 22:32:49 complex join question
Previous Message Louis-David Mitterrand 2010-02-12 11:57:47 Re: "left join" not working?