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 931A8D1B510 for ; Mon, 27 Oct 2003 03:28:12 +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 63513-02 for ; Sun, 26 Oct 2003 23:27:44 -0400 (AST) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 3F7B7D1B52B for ; Sun, 26 Oct 2003 23:27:40 -0400 (AST) Received: (qmail 11852 invoked by uid 500); 27 Oct 2003 03:34:43 -0000 Date: Sun, 26 Oct 2003 21:34:43 -0600 From: Bruno Wolff III To: yusuf0478@netscape.net Cc: pgsql-sql@postgresql.org Subject: Re: Query Help using Except Message-ID: <20031027033443.GA11800@wolff.to> Mail-Followup-To: yusuf0478@netscape.net, pgsql-sql@postgresql.org References: <1288A498.21F60EA2.037EC703@netscape.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1288A498.21F60EA2.037EC703@netscape.net> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/337 X-Sequence-Number: 15737 On Thu, Oct 23, 2003 at 14:17:08 -0400, yusuf0478@netscape.net wrote: > > I can't do the following, since the number of selected columns have to match: One option is to use where NOT EXISTS instead of EXCEPT. Another way would be to add A.id to the rows in the set difference using a join. I expect the second method would be slower and that you should try using NOT EXISTS. > > select A.id > , A.charge > , B.user_id > , C.employee_id > from A > inner join B using (user_id) > inner join C using (employee_id) > > except > > select X.charge > , Y.user_id > , Z.employee_id > from X > inner join Y using (user_id) > inner join Z using (employee_id)