Re: "left join" not working?

Поиск
Список
Период
Сортировка
От msi77
Тема Re: "left join" not working?
Дата
Msg-id 23141265975830@webmail112.yandex.ru
обсуждение исходный текст
Ответ на "left join" not working?  (Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>)
Список pgsql-sql
> where p.id_line=1

this filters rows after join was applied. Try this

select c.id_currency,max(p.modified_on) from currency c left join 
price_line p using (id_currency) where (p.id_line=1 or p.id_line is null) group by 
c.id_currency; 


> 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 
> 

Яндекс.Почта. Письма есть. Спама - нет. http://mail.yandex.ru/nospam/sign


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Oliveiros C,"
Дата:
Сообщение: Re: "left join" not working?
Следующее
От: Louis-David Mitterrand
Дата:
Сообщение: Re: "left join" not working?