Mysql多表聯合更新、刪除
阿新 • • 發佈:2018-11-06
UPDATE snyts_user u INNER JOIN snyts_order o ON u.user_id = o.user_id INNER JOIN snyts_refund_order r ON o.order_id = r.order_id SET u.training_times = u.training_times - 1 WHERE r.refund_order_id = :refundOrderId DELETE ucr FROM snyts_user_class_rel ucr INNER JOIN snyts_order o ON ucr.user_id = o.user_id AND ucr.class_id = o.class_id INNER JOIN snyts_refund_order r ON o.order_id = r.order_id WHERE r.refund_order_id = :refundOrderId