Update Table
-
Hi, This is really bugging me, I have a product table with a quantity column, When a user buys an item I want the quantity column to change to "SOLD" or 0. The thing is, how do I do this if a customer buys more than one item at a time? I need to be able to pass the number of product ID's to the database and then let a stored procedure UPDATE the selected ProductID's Quantity column to "SOLD" or 0. Somebody help or put me in the right direction! I have tried all i can think of but my SQL knowledge is limited! Thanks in advance JetSet
-
Hi, This is really bugging me, I have a product table with a quantity column, When a user buys an item I want the quantity column to change to "SOLD" or 0. The thing is, how do I do this if a customer buys more than one item at a time? I need to be able to pass the number of product ID's to the database and then let a stored procedure UPDATE the selected ProductID's Quantity column to "SOLD" or 0. Somebody help or put me in the right direction! I have tried all i can think of but my SQL knowledge is limited! Thanks in advance JetSet
Hope this will help, when the user buy 3 item with the product ID 2, execute the stored procedure passing the quantity and the ID
update TableName set Qty=Qty-@Qty where ID=@ID
Work hard and a bit of luck is the key to success.
You don`t need to be genius, to be rich.
-
Hope this will help, when the user buy 3 item with the product ID 2, execute the stored procedure passing the quantity and the ID
update TableName set Qty=Qty-@Qty where ID=@ID
Work hard and a bit of luck is the key to success.
You don`t need to be genius, to be rich.
thanks, I worked it out in the end, and it only took me the whole day!!! UPDATE Products SET ProdQuantity = 0 WHERE ProductID =(SELECT ProductID FROM ShoppingCart WHERE ProductID = Products.ProductID and ShoppingCart.CartID=@CartID) Their you go Thanks again