Re: left joins

Поиск
Список
Период
Сортировка
Искать
От
Richard Huxton
Тема
Re: left joins
Дата
Msg-id
42CBB2AF.2010601@archonet.com
Ответ на
left joins (Grant Morgan)
Список
Дерево обсуждения
left joins "Grant Morgan" <grant@ryuuguu.com>
Re: left joins "Nick Stone" <nick@harelane.com>
Re: left joins Ragnar Hafstað <gnari@simnet.is>
Re: left joins Tony Wasson <ajwasson@gmail.com>
Re: left joins "Grant Morgan" <grant@ryuuguu.com>
Re: left joins Tom Lane <tgl@sss.pgh.pa.us>
Re: left joins Richard Huxton <dev@archonet.com>
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 по дате отправления
От: Grant Morgan
Дата:
Сообщение: left joins
От: Nick Stone
Дата:
Сообщение: Re: left joins
FAQ