Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id A9BBB9FBA8C for ; Thu, 12 Apr 2007 15:32:52 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 69625-03-4 for ; Thu, 12 Apr 2007 15:32:44 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from zebedee.cranntara.net (zebedee.cranntara.net [91.186.7.79]) by postgresql.org (Postfix) with ESMTP id 6277D9FBAFA for ; Thu, 12 Apr 2007 15:32:44 -0300 (ADT) Received: from dial-dynamic-62-69-36-219.surfdial.murphx.net ([62.69.36.219] helo=bolek.coachhouse) by zebedee.cranntara.net with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.62) (envelope-from ) id 1Hc460-0002E3-DH for pgsql-sql@postgresql.org; Thu, 12 Apr 2007 19:32:39 +0100 Received: from [192.168.0.32] (helo=[192.168.0.32]) by bolek.coachhouse with esmtp (Exim 4.50) id 1Hc45b-0007Jt-CP for pgsql-sql@postgresql.org; Thu, 12 Apr 2007 19:32:11 +0100 Message-ID: <461E7B2A.6040507@numerixtechnology.de> Date: Thu, 12 Apr 2007 19:32:10 +0100 From: T E Schmitz Reply-To: mailreg@numerixtechnology.de User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: replace EXCEPT by JOIN Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/132 X-Sequence-Number: 28132 The following construct does what I need but is there a better way of expressing this? select * from ( SELECT DISTINCT section.section_pk FROM ITEM LEFT JOIN product product ON Item.product_fk = product.product_pk LEFT JOIN section section ON product.section_fk = section.section_pk WHERE item.export = 'f' EXCEPT SELECT DISTINCT section.section_pk FROM ITEM LEFT JOIN product product ON Item.product_fk = product.product_pk LEFT JOIN section section ON product.section_fk = section.section_pk WHERE item.export = 't' ) as X