Re: Joining on a column that might be null

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Joining on a column that might be null
Дата
Msg-id 16739.983332850@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Joining on a column that might be null  ("James McMurry" <jmcmurry@pobox.com>)
Список pgsql-novice
"James McMurry" <jmcmurry@pobox.com> writes:
> item.created_by contains entries from member.member_id, and I'd like to
> select records from item with the full member_name:
> select a.item_id, a.item_name, b.member_name
> from item a, member b
> where a.created_by = b.member_id
> The problem I'm having is that created_by can be null.  The above statement
> won't give me results for those records.

I believe what you're looking for is an "outer join".   We have this for
real in PG 7.1, but in earlier releases you have to fake it with a UNION
construct.  See http://www.postgresql.org/docs/faq-english.html#4.24

            regards, tom lane

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

Предыдущее
От: "James McMurry"
Дата:
Сообщение: Re: Joining on a column that might be null
Следующее
От: Allen.Kimberly@epamail.epa.gov
Дата:
Сообщение: postgres 6.5.2 questions