Re: LEFT JOIN on one and/or another column (thanks)

From: "Octavio Alvarez" <alvarezp(at)alvarezp(dot)ods(dot)org>
To: "Bruno Wolff III" <bruno(at)wolff(dot)to>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: LEFT JOIN on one and/or another column (thanks)
Date: 2004-01-29 18:40:46
Message-ID: 2500.63.84.67.25.1075401646.squirrel@alvarezp.ods.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Yes, Bruno. Thank you very much. That's what I was looking for, but since
I hadn't used CASE nor COALESCE, I didn't know it was easier that way.

The idea is that on a column I have info about a routine task, and in
another one I have info about human-made changes to the time of that task,
like assigning a different task, or moving it to another moment, and the
query I'm trying to make should answer what tasks should be done now.

Thank you.

Bruno Wolff III said:
> On Wed, Jan 28, 2004 at 20:27:00 -0800,
> Octavio Alvarez <alvarezp(at)alvarezp(dot)ods(dot)org> wrote:
>>
>> Hi. I have a table with two foreign keys (1 field each), like in
>>
>> id | serial
>> ext_key_original | integer
>> ext_key_exception | integer
>>
>> I'd like to join on the original, except when exception <> NULL, but I
>> can't quite figure out how to do so.
>
> I am not completely sure from your description what exactly you are trying
> to do, but it sounds like you can left join your table to the two foreign
> key tables and then use coallesce to grab the value from the appropiate
> joined table.

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

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2004-01-29 18:40:55 Re: query not using index for descending records?
Previous Message Stephan Szabo 2004-01-29 18:27:57 Re: query not using index for descending records?