[SQL] Query Help

2003-10-23 Thread yusuf0478
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)

Can someone help me with the query?

Thanks in advance.

__
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397

Get AOL Instant Messenger 5.1 free of charge.  Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promo=380455

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


[SQL] Query Help using Except

2003-10-23 Thread yusuf0478
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)


Can someone help me with the query?

Thanks in advance.

__
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397

Get AOL Instant Messenger 5.1 free of charge.  Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promo=380455

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [SQL] Query Help

2003-10-23 Thread yusuf0478
Wouldn't that return every A.id ? since A.id would be compared to -1, and the wouldnt' 
be the same.

I want:

select min(A.id) such that A.charge, B.userid, C.employee_id in 
(
 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)
)


"scott.marlowe" <[EMAIL PROTECTED]> wrote:

>On Thu, 23 Oct 2003 [EMAIL PROTECTED] 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
>
>???
>
>
>---(end of broadcast)---
>TIP 6: Have you searched our list archives?
>
>   http://archives.postgresql.org
>

__
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397

Get AOL Instant Messenger 5.1 free of charge.  Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promo=380455

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster