replace EXCEPT by JOIN

From: T E Schmitz <mailreg(at)numerixtechnology(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: replace EXCEPT by JOIN
Date: 2007-04-12 18:32:10
Message-ID: 461E7B2A.6040507@numerixtechnology.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Browse pgsql-sql by date

  From Date Subject
Next Message PostgreSQL Admin 2007-04-12 19:51:07 Re: Replace string
Previous Message ezequias 2007-04-12 12:23:39 ERROR: column "crc" does not exist