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 11:35:02 |
Message-ID: | 34E07A4C4CDA4FFCB56CD63C675568ED@marktestcr.marktest.pt |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(at)apartia(dot)org>
To: <pgsql-sql(at)postgresql(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
From | Date | Subject | |
---|---|---|---|
Next Message | msi77 | 2010-02-12 11:57:10 | Re: "left join" not working? |
Previous Message | Louis-David Mitterrand | 2010-02-12 11:14:53 | "left join" not working? |