我有表A:
id name product_id shipped
1 Apple 10 100
2 Orange 11 110
3 Banana 12 0
4 Mango 13 0
表B:
id product_id qty order_id
1 10 100 2
2 11 110 2
3 12 120 3
4 13 130 2
我需要更新数量
UPDATE table_B SET qty=0 WHERE order_id=2
AND table_B.product_id = table_A.product_id
table_A.product_id来自脚本。我怎样才能做到这一点?谢谢
答案 0 :(得分:1)
UPDATE table_B b
LEFT JOIN table_A a
ON b.product_id = a.product_id
SET b.qty= 0 WHERE b.order_id=2