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 |
|
vgr.raju
Yak Posting Veteran
95 Posts |
Posted - 2005-07-16 : 21:41:35
|
| Use Northwindgoselect c.customerid,c.companyname,o.orderid,od.productid,p.productnamefrom customers c join orders o on c.customerid=o.customeridjoin [order details] od on o.orderid=od.orderidjoin products p on p.productid=od.productid and p.productid in (17,40)order by c.customeridHello ,using this query i am getting the both 17,40.It acts like a 'or' operator.I want to return the resultset which has got both 17,40.Effectively I want 'and'operator.Can someone write the query for this.Thank you. |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-07-17 : 05:26:40
|
Not sure this is the most efficient method, but hopefully it will work!SELECT O.orderidFROM orders OWHERE 2 = ( SELECT COUNT(distinct OD.productid) FROM [order details] OD WHERE OD.orderid = O.orderid AND OD.productid IN (17, 40) ) Kristen |
 |
|
|
vgr.raju
Yak Posting Veteran
95 Posts |
Posted - 2005-07-17 : 17:20:35
|
| Thank you kristen |
 |
|
|
|
|
|