Re: Query Help

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: <yusuf0478(at)netscape(dot)net>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Query Help
Date: 2003-10-23 18:34:13
Message-ID: Pine.LNX.4.33.0310231232480.21690-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, 23 Oct 2003 yusuf0478(at)netscape(dot)net wrote:

> I'm interested in finding the minimim A.id such that the following holds:
>
> select 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)
>
> --
>
> I can't do the following, since the number of selected columns have to match:
>
> 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)

Maybe you can add a dummy field in the second half like this:

except

select -1
, X.charge
, Y.user_id
, Z.employee_id

???

In response to

  • Query Help at 2003-10-23 18:33:09 from yusuf0478

Browse pgsql-sql by date

  From Date Subject
Next Message Jeff Kowalczyk 2003-10-23 19:33:24 help on update subselect with joins
Previous Message yusuf0478 2003-10-23 18:33:09 Query Help