【问题标题】:Product Quantity will decrease When Order is Placed in ASP.net在 ASP.net 下订单时产品数量会减少
【发布时间】:2017-11-13 17:05:38
【问题描述】:

我有一个带有 quantity 列的 product 表 和一个带有 productIdcart 表 PurchaseQuantity 列。 根据clientId从购物车表中选择所有productId和PurchaseQuantity的代码是什么(可以多于一个)。之后,特定产品数量根据购买的数量减少。 例如:

product table
productid      Quantity
  1                  10
  2                  20

cart table
productId     purchasedQuantity
   1                  5
   2                  3


 now product table will be
 productid      Quantity
   1                  5
   2                  17 

对此的 SQL 查询是什么?有什么解决办法??

【问题讨论】:

    标签: mysql asp.net sql-server


    【解决方案1】:
    SELECT p.productid, p.Quantity-ct.purchasedQuantity
    from product p
    left join carttable ct 
    on p.productid=ct.productid
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-04
      • 2017-01-28
      • 2020-09-05
      • 1970-01-01
      • 1970-01-01
      • 2016-08-16
      • 2020-12-16
      • 1970-01-01
      相关资源
      最近更新 更多