X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C3EC7D1CAF3 for ; Thu, 29 Jan 2004 04:27:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 40133-09 for ; Thu, 29 Jan 2004 00:27:01 -0400 (AST) Received: from alvarezp.ods.org (unknown [200.77.201.28]) by svr1.postgresql.org (Postfix) with ESMTP id 4D7ECD1C9F3 for ; Thu, 29 Jan 2004 00:26:53 -0400 (AST) Received: (from apache@localhost) by alvarezp.ods.org (8.11.6/8.11.6) id i0T4R1x19364; Wed, 28 Jan 2004 20:27:01 -0800 X-Authentication-Warning: alvarezp.ods.org: apache set sender to alvarezp@alvarezp.ods.org using -f Received: from 63.84.67.25 (SquirrelMail authenticated user alvarezp) by alvarezp.ods.org with HTTP; Wed, 28 Jan 2004 20:27:00 -0800 (PST) Message-ID: <1533.63.84.67.25.1075350420.squirrel@alvarezp.ods.org> Date: Wed, 28 Jan 2004 20:27:00 -0800 (PST) Subject: LEFT JOIN on one and/or another column From: "Octavio Alvarez" To: pgsql-sql@postgresql.org Reply-To: alvarezp@alvarezp.ods.org User-Agent: SquirrelMail/1.4.0-1.7.x MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/244 X-Sequence-Number: 16637 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@alvarezp.ods.org. Agradezco que sus correos sean enviados siempre a esta dirección.