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 |
|
Dabbler
Starting Member
7 Posts |
Posted - 2005-02-12 : 08:56:46
|
| Given two tables Products and Inventory, I'm trying to set the Inventory QtyInStock = 0 where Products VendorID = 11and Inventory.ProductID = Products.uidMy query generates the follwoing error:"ADO error: Only one expression can be specified in the select list when a subquery is not introduced with EXISTS"I tried using EXISTS but wound up setting all rows to 0!UPDATE InventorySET QtyInStock = 0WHERE (Inventory.ProductID IN (SELECT Inventory.ProductID, Products.uid, Products.VendorId FROM Inventory JOIN Products ON Inventory.ProductID = Products.uid WHERE (Products.VendorId = 11)))Thanks for any help with this.Dabbler |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-02-12 : 09:45:42
|
| DOn't get carried away with brackets they're just confusing.update InventorySET QtyInStock = 0from Inventory ijoin Products pon Inventory.ProductID = Products.uidand Products.VendorId = 11your query would have beenUPDATE InventorySET QtyInStock = 0WHERE Inventory.ProductID IN(SELECT Products.uid FROM Products WHERE Products.VendorId = 11)==========================================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. |
 |
|
|
Dabbler
Starting Member
7 Posts |
Posted - 2005-02-12 : 10:19:08
|
| Sweet, thanks much, that did the trick.your query would have beenUPDATE InventorySET QtyInStock = 0WHERE Inventory.ProductID IN(SELECT Products.uid FROM Products WHERE Products.VendorId = 11)Dabbler |
 |
|
|
|
|
|