From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Grant Morgan <grant(at)ryuuguu(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: left joins |
Date: | 2005-07-06 10:30:07 |
Message-ID: | 42CBB2AF.2010601@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Nick Stone | 2005-07-06 10:33:03 | Re: left joins |
Previous Message | Grant Morgan | 2005-07-06 10:01:54 | left joins |