Skip site navigation (1) Skip section navigation (2)

LEFT JOIN on one and/or another column

From: "Octavio Alvarez" <alvarezp(at)alvarezp(dot)ods(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: LEFT JOIN on one and/or another column
Date: 2004-01-29 04:27:00
Message-ID: 1533.63.84.67.25.1075350420.squirrel@alvarezp.ods.org (view raw or flat)
Thread:
Lists: pgsql-sql
Hi. I have a table with two foreign keys (1 field each), like in

 id                | serial
 ext_key_original  | integer
 ext_key_exception | integer

They mean different things, as one refers to a typical value, and the
other one refers to an exception that applies for that tuple.

Each key references a different table, one with typical data, and one with
exception data.

I'd like to join on the original, except when exception <> NULL, but I
can't quite figure out how to do so.

Can anyone help?

Thanks you. :-)

Octavio.

-- 
Octavio Alvarez.
E-mail: alvarezp(at)alvarezp(dot)ods(dot)org(dot)

Agradezco que sus correos sean enviados siempre a esta dirección.

Responses

pgsql-sql by date

Next:From: KumarDate: 2004-01-29 06:11:18
Subject: SQL Query for Top Down fetching of childs
Previous:From: Tom LaneDate: 2004-01-28 23:03:25
Subject: Re: Question about isolation

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group