SQL Update Statement

后端 未结 1 345
梦毁少年i
梦毁少年i 2021-01-28 06:54

I have 2 tables, Products and ShoppingCart and I would like to update and decrease the product\'s \'Quantity\' of the Products table based on the Product name and Quantity speci

相关标签:
1条回答
  • 2021-01-28 07:02

    You should have a product id. However:

     UPDATE Products p
     INNER JOIN [Shopping Cart] s
     ON p.[Product Name] = s.[Product Name]
     SET p.ProductQty = p.ProductQty - s.ProductQty
    

    You should get rid of spaces in field and table names, as well.

    0 讨论(0)
提交回复
热议问题