且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Delete语句中使用Sum和Inner Join

更新时间:2023-01-19 20:36:20

Hmmm. . .如果需要进行汇总,则需要在join:

Hmmm . . . If you need to do aggregation, you need to do it before the join:

Delete t
    from TablenName t join
         (select op.product_id, sum(op.quantity) as sumquantity
          from oc_order_product op
          group by op.product_id
         ) op
         on op.product_id = t.product_id and op.sumquantity < 2;