From: Oliveiros C, <oliveiros.cristina@marktest.pt>
To: Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>
To: pgsql-sql@postgresql.org
Subject: Re: "left join" not working?
Date: Fri, 12 Feb 2010 11:35:02 -0000
Message-ID: <34E07A4C4CDA4FFCB56CD63C675568ED@marktestcr.marktest.pt> (raw)
References: <20100212111453.GA16318@apartia.fr>
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...
Didn't do any tests, it's just a guess...
Best,
Oliveiros
----- Original Message -----
From: "Louis-David Mitterrand" <vindex+lists-pgsql-sql@apartia.org>
To: <pgsql-sql@postgresql.org>
Sent: Friday, February 12, 2010 11:14 AM
Subject: [SQL] "left join" not working?
> Hi,
>
> This query:
>
> select c.id_currency,max(p.modified_on) from currency c left join
> price_line p using (id_currency) where p.id_line=1 group by
> c.id_currency;
>
> doesn't list all c.id_currency's, only those with a price_line. However
> this one does:
>
> select c.id_currency,max(p.modified_on) from currency c left join
> price_line p on (p.id_currency = c.id_currency and p.id_line=1) group by
> c.id_currency;
>
> How come?
>
> Thanks,
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: oliveiros.cristina@marktest.pt, vindex+lists-pgsql-sql@apartia.org
Subject: Re: "left join" not working?
In-Reply-To: <34E07A4C4CDA4FFCB56CD63C675568ED@marktestcr.marktest.pt>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox