pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Octavio Alvarez <alvarezp@alvarezp.ods.org>
To: Bruno Wolff III <bruno@wolff.to>
Cc: pgsql-sql@postgresql.org
Subject: Re: LEFT JOIN on one and/or another column (thanks)
Date: Thu, 29 Jan 2004 10:40:46 -0800 (PST)
Message-ID: <2500.63.84.67.25.1075401646.squirrel@alvarezp.ods.org> (raw)
In-Reply-To: <20040129130041.GB17068@wolff.to>
References: <1533.63.84.67.25.1075350420.squirrel@alvarezp.ods.org>
	<20040129130041.GB17068@wolff.to>


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@alvarezp.ods.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@alvarezp.ods.org.

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



Message-ID: <2500.63.84.67.25.1075401646.squirrel@alvarezp.ods.org>
Permalink:  ../2500.63.84.67.25.1075401646.squirrel@alvarezp.ods.org/
Also on:    postgresql.org/message-id/2500.63.84.67.25.1075401646.squirrel@alvarezp.ods.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: alvarezp@alvarezp.ods.org, bruno@wolff.to
  Subject: Re: LEFT JOIN on one and/or another column (thanks)
  In-Reply-To: <2500.63.84.67.25.1075401646.squirrel@alvarezp.ods.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox