Mysql多表联合更新、删除

            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

 

posted @ 2018-11-06 18:24  feibazhf  阅读(155)  评论(0编辑  收藏  举报