Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id E42F863296F for ; Fri, 12 Feb 2010 07:59:22 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 11770-05 for ; Fri, 12 Feb 2010 11:58:41 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from forward12.mail.yandex.net (forward12.mail.yandex.net [95.108.130.94]) by mail.postgresql.org (Postfix) with ESMTP id D66BD63261E for ; Fri, 12 Feb 2010 07:57:13 -0400 (AST) Received: from webmail112.yandex.ru (webmail112.yandex.ru [95.108.130.11]) by forward12.mail.yandex.net (Yandex) with ESMTP id 5E2112428046; Fri, 12 Feb 2010 14:57:11 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1265975831; bh=F2WZp5kCRzfzOcGltKSPFic88ELyUOlKz+WzG84jfCw=; h=From:To:Cc:In-Reply-To:References:Subject:MIME-Version:Message-Id: Date:Content-Transfer-Encoding:Content-Type; b=qJw2Rk61tvLuDNUCAudrkoByxqjOxFzrayVXTihVriEijVOapF1Z+A+Aub9oer9x6 YLrxRKzKrj+FswX1etAmIrW6V9WD0rm8plx+HpxzfQ2T6snFclQ4aSW30fvQoFFJd6 ndVBklXpOyZuHiOlCB2MYurL6NL8CXXP/KqIZKPQ= Received: from localhost (localhost.localdomain [127.0.0.1]) by webmail112.yandex.ru (Yandex) with ESMTP id 41CE52358051; Fri, 12 Feb 2010 14:57:11 +0300 (MSK) X-Yandex-Spam: 1 X-Yandex-Front: webmail112 X-Yandex-TimeMark: 1265975831 Received: from user-23.81.118.217.in-addr.arpa (user-23.81.118.217.in-addr.arpa [217.118.81.23]) by mail.yandex.ru with HTTP; Fri, 12 Feb 2010 14:57:09 +0300 From: msi77 To: Louis-David Mitterrand Cc: pgsql-sql@postgresql.org In-Reply-To: <20100212111453.GA16318@apartia.fr> References: <20100212111453.GA16318@apartia.fr> Subject: Re: "left join" not working? MIME-Version: 1.0 Message-Id: <23141265975830@webmail112.yandex.ru> Date: Fri, 12 Feb 2010 14:57:10 +0300 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=koi8-r X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=-10 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 201002/45 X-Sequence-Number: 33644 > 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