Re: left joins - Mailing list pgsql-sql

From Richard Huxton
Subject Re: left joins
Date
Msg-id 42CBB2AF.2010601@archonet.com
Whole thread Raw
In response to left joins  ("Grant Morgan" <grant@ryuuguu.com>)
List 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


pgsql-sql by date:

Previous
From: "Grant Morgan"
Date:
Subject: left joins
Next
From: "Nick Stone"
Date:
Subject: Re: left joins