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.
Author |
Topic |
r2k
Starting Member
1 Post |
Posted - 2014-11-02 : 12:07:57
|
Can anyone tell me how do we take care of only condition in sql?for ex Find the sids of suppliers who supply only red partsschema is suppliers(sid,sname,address)parts(pid,pname,color)catalog(pid,sid,price)I wrote this as my answer but it is giving name of the ids of all the suppliers who supply red part:select distinct c.sidfrom catalog c, parts pwhere not exists (select * from parts p where p.pid = c.pid and p.color <> 'red') |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-11-02 : 13:46:16
|
select distinct c.sidfrom catalog cjoin parts p on p.pid = c.pidwhere p.color = 'red' |
|
|
|
|
|