Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 subqueyr problem

Author  Topic 

twinklestar0802
Starting Member

17 Posts

Posted - 2005-06-05 : 14:51:29
guys.. im getting an error "Incorrect syntax near ','.".. why?
supplierinvocie and companypo are composite keys.... im trying to subqeruy them. .help
select * from supplierinvociedetails where (supplierinvoice,companypo)
in(select supplierinvoice,companypo from supplierinvoice)

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2005-06-05 : 15:00:05
The easiest way to do this would be with a join:
select
sid.* --<--- select * is bad practice, list the columns You want
from
supplierinvoice si join supplierinvociedetails sid
on si.supplierinvoice = sid.supplierinvoice
and si.companypo = sid.companypo


The IN operator can't take multiple arguments like You tried.
You would have to use the EXISTS clause:

select * from supplierinvociedetails sid
where exists( select * from supplierinvoice si
where si.supplierinvoice = sid.supplierinvoice
and si.companypo = sid.companypo)


rockmoose
Go to Top of Page
   

- Advertisement -