pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Grant Morgan <grant@ryuuguu.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: left joins
Date: Wed, 06 Jul 2005 11:30:07 +0100
Message-ID: <42CBB2AF.2010601@archonet.com> (raw)
In-Reply-To: <op.sthktgypuogdv0@localhost.localdomain>
References: <op.sthktgypuogdv0@localhost.localdomain>
Grant Morgan wrote:
> I am having a problem with left joins in Postgresql.(probably my
> misunderstanding of left joins)
>
> My first Query returns
> 70,000
>
> select count(*)
> from h
> where h.tn > 20
> and h.tn < 30
>
> my left join
> returns only 34,000
>
> select count(*)
> from h left join p using (r,pos)
> where h.tn > 20
> and h.tn < 30
> and p.r_order=1
>
> since it is a left join I though I should get a number no smaller in the
> left join than the original unjoined query.
You don't. You make the left join, then apply another condition
"p.r_order=1". If you want to demonstrate a problem, you'll need to make
sure the queries are the same.
--
Richard Huxton
Archonet Ltd
view thread (10+ messages) latest in thread
Message-ID: <42CBB2AF.2010601@archonet.com> Permalink: ../42CBB2AF.2010601@archonet.com/ Also on: postgresql.org/message-id/42CBB2AF.2010601@archonet.com ·
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: dev@archonet.com, grant@ryuuguu.com Subject: Re: left joins In-Reply-To: <42CBB2AF.2010601@archonet.com> * 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