Returning null for joined tables when one column non existant

From: Madison Kelly <linux(at)alteeve(dot)com>
To: postgres list <pgsql-general(at)postgresql(dot)org>
Subject: Returning null for joined tables when one column non existant
Date: 2009-02-26 18:30:27
Message-ID: 49A6DFC3.4060309@alteeve.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

I've got a query that crosses a few tables. For example:

SELECT
a.foo, b.bar, c.baz
FROM
aaa a, bbb b, ccc c
WHERE
a.a_id=b.b_a_id AND a.a_id=c.c_a_id AND a.a_id=1;

Obviously, if there is no match in 'bbb' or 'ccc' then nothing will
be returned, even if there is a match in one or both of the other
tables. Is there a way to say something like 'b.bar OR NULL' to make
sure that the matching columns with data still show and ones without a
match return NULL (or some string)?

Thanks!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Maxim Boguk 2009-02-26 18:49:46 Re: Postgresql selecting strange index for simple query
Previous Message Andrew Gould 2009-02-26 17:36:59 Re: Off Topic: ICD-10 codes in a database table?