Re: left joins
От | Tom Lane |
---|---|
Тема | Re: left joins |
Дата | |
Msg-id | 26225.1120661054@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | left joins ("Grant Morgan" <grant@ryuuguu.com>) |
Список | pgsql-sql |
"Grant Morgan" <grant@ryuuguu.com> writes: > 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 seems to be acting > like an inner join. Well, yeah. The condition p.r_order=1 will return NULL (effectively FALSE) for any row in which p.r_order is NULL, so none of the null-extended rows can survive the WHERE filter, so it's effectively an inner join. Recent versions of PG actively recognize this case and reduce the LEFT JOIN to plain JOIN, but even if we did not do that you'd get the same result. I've heard it claimed that Oracle produces different results; if true, it must have something to do with their rather standards-challenged interpretation of NULL ... regards, tom lane
В списке pgsql-sql по дате отправления: