Re: Query Help using Except

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: yusuf0478(at)netscape(dot)net
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Query Help using Except
Date: 2003-10-27 03:34:43
Message-ID: 20031027033443.GA11800@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, Oct 23, 2003 at 14:17:08 -0400,
yusuf0478(at)netscape(dot)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)

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Antony Gubert 2003-10-27 08:11:55 unsubscribe
Previous Message Christopher Browne 2003-10-26 20:52:05 Re: index and min()