Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id B52ED4ADAAB for ; Sat, 10 Dec 2011 12:03:54 -0400 (AST) Received: from marvin.klingler.net ([91.212.121.244]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RZPOy-0004LL-Nw for pgsql-sql@postgresql.org; Sat, 10 Dec 2011 16:03:54 +0000 Received: from [10.0.60.1] (vpn.klingler.net [213.193.121.98]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by marvin.klingler.net (Postfix) with ESMTPSA id 0A04633C78 for ; Sat, 10 Dec 2011 17:03:33 +0100 (CET) Date: Sat, 10 Dec 2011 17:03:32 +0100 From: Richard Klingler To: pgsql-sql@postgresql.org Message-ID: <20111210170332479879.3df30525@klingler.net> Subject: conditional FROM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: GyazMail version 1.5.11 X-Pg-Spam-Score: -2.4 (--) X-Archive-Number: 201112/37 X-Sequence-Number: 36098 Good day... I'm trying to build a query for PGSQL 9.1 where a table has two references with only one being used depending of the type of entry.. For example, the table has following simplified structure: portid primary key port2node index to table node port2card index to table card So how can I do a conditional FROM clause in the query depending on the column port2node and port2card? If port2card is Null or 0 I don't want it in the FROM clause as the query will return unneccessary duplicate row...the same goes for port2node being Null or 0... thanx in advance richard