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 2005 Forums
 Transact-SQL (2005)
 Need Query

Author  Topic 

satish.gorijala
Posting Yak Master

182 Posts

Posted - 2010-12-17 : 04:37:49
Hi, I have table like this.

CID TID
12 P5
12 p6
16 p5
16 P6
78 P6
80 p6
85 P5


My requirement is, if i took one particular CID then the TID should be either P5 or P5,P6 but not only p6.

For exmaple, if i took CID =12, then the TID for this one is P5 and P6. so i will consider this.
IF i took CID = 80, then it exists in only P6. so i wont consider
If i took CID = 85, then it exists in only P5. then i condiser this

So i am looking for the query of this type.
Select CID from table where PID ='P5' or PID in (P5,P6) and PID <>'P6'

Please give the correct query


developer :)

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-12-17 : 04:59:06
Select CID from table where PID ='P5'


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -