Re: Query Help - Mailing list pgsql-sql

From scott.marlowe
Subject Re: Query Help
Date
Msg-id Pine.LNX.4.33.0310231232480.21690-100000@css120.ihs.com
Whole thread Raw
In response to Query Help  (yusuf0478@netscape.net)
List pgsql-sql
On Thu, 23 Oct 2003 yusuf0478@netscape.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

???



pgsql-sql by date:

Previous
From: Manuel Sugawara
Date:
Subject: Re: Regular expression problem
Next
From: yusuf0478@netscape.net
Date:
Subject: Query Help using Except