pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: yusuf0478@netscape.net
Cc: pgsql-sql@postgresql.org
Subject: Re: Query Help using Except
Date: Sun, 26 Oct 2003 21:34:43 -0600
Message-ID: <20031027033443.GA11800@wolff.to> (raw)
In-Reply-To: <1288A498.21F60EA2.037EC703@netscape.net>
References: <1288A498.21F60EA2.037EC703@netscape.net>

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)



view thread (2+ messages)

Message-ID: <20031027033443.GA11800@wolff.to>
Permalink:  ../20031027033443.GA11800@wolff.to/
Also on:    postgresql.org/message-id/20031027033443.GA11800@wolff.to

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bruno@wolff.to, yusuf0478@netscape.net
  Subject: Re: Query Help using Except
  In-Reply-To: <20031027033443.GA11800@wolff.to>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox