Re: Joining on a column that might be null - Mailing list pgsql-novice

From Tom Lane
Subject Re: Joining on a column that might be null
Date
Msg-id 16739.983332850@sss.pgh.pa.us
Whole thread Raw
In response to Joining on a column that might be null  ("James McMurry" <jmcmurry@pobox.com>)
List 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 by date:

Previous
From: "James McMurry"
Date:
Subject: Re: Joining on a column that might be null
Next
From: Allen.Kimberly@epamail.epa.gov
Date:
Subject: postgres 6.5.2 questions