left joins

Поиск
Список
Период
Сортировка
От Grant Morgan
Тема left joins
Дата
Msg-id op.sthktgypuogdv0@localhost.localdomain
обсуждение исходный текст
Ответы Re: left joins  (Richard Huxton <dev@archonet.com>)
Re: left joins  ("Nick Stone" <nick@harelane.com>)
Re: left joins  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
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. It
seemsto be acting like an inner join. Both of these are tables not views and both have hash indices on r column. I have
triedleft joins, right joins , and both using and on , nothing seems make a difference.
 
Questions
1)should a left join return atleast as many rows as the unjoined left table?
2)am I doing something wrong above?
3)If am not doing anything wrong is this postgresql problem and is there a work around?


Cheers,
Grant


В списке pgsql-sql по дате отправления:

Предыдущее
От: Bricklen Anderson
Дата:
Сообщение: Re: Create connection with Oracle database from Postgres plpgsql
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: left joins