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 |
|
lemondash
Posting Yak Master
159 Posts |
Posted - 2008-04-08 : 05:38:26
|
| I have a table which has two colounms DocumentId,ProductId.The documentId is not unique it will appera in the table for what ever productID is linked to it.But i want to bring back the documentId's which has say for example the productID of 4,39 and 33any ideas Regards Lee |
|
|
pravin14u
Posting Yak Master
246 Posts |
Posted - 2008-04-08 : 05:39:38
|
| select distinct documentid from tablename where Productid in(4,39,33)Prakash.PThe secret to creativity is knowing how to hide your sources! |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-04-08 : 05:48:06
|
| You want to bring documentid which is linked to all three of the productids or either of them?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
lemondash
Posting Yak Master
159 Posts |
Posted - 2008-04-08 : 05:51:18
|
| I tried that, but dosen't work.Because it will look any of the values (4,39,33), but i need to bring but the ones that the documentId is equal to 4,29 and 33 |
 |
|
|
lemondash
Posting Yak Master
159 Posts |
Posted - 2008-04-08 : 05:51:49
|
| Yes. All three of the productids |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2008-04-08 : 05:52:54
|
| select documentid from tblwhere Productid in (4,39,33)group by Productidhaving count(distinct Productid) = 3==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
lemondash
Posting Yak Master
159 Posts |
Posted - 2008-04-08 : 06:47:52
|
| Works a dream cheers !!!!!! |
 |
|
|
|
|
|