pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: msi77 <msi77@yandex.ru>
To: Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: "left join" not working?
Date: Fri, 12 Feb 2010 14:57:10 +0300
Message-ID: <23141265975830@webmail112.yandex.ru> (raw)
In-Reply-To: <20100212111453.GA16318@apartia.fr>
References: <20100212111453.GA16318@apartia.fr>

> 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



view thread (5+ messages)  latest in thread

Message-ID: <23141265975830@webmail112.yandex.ru>
Permalink:  ../23141265975830@webmail112.yandex.ru/
Also on:    postgresql.org/message-id/23141265975830@webmail112.yandex.ru

 · 

reply

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: msi77@yandex.ru, vindex+lists-pgsql-sql@apartia.org
  Subject: Re: "left join" not working?
  In-Reply-To: <23141265975830@webmail112.yandex.ru>

* 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