mysql数据库在批量更新某表的字段时,语法如下:
UPDATE A AS a
INNER JOIN (
SELECT
*
FROM
A
WHERE
....
) AS b ON a.order_id = b.order_id
SET a.pay_status = 2 ,a.abnormal = 4;
举例:
UPDATE Yamibuy_Master.xysc_order_info AS oi
INNER JOIN (
SELECT
order_id,order_sn,pay_status,abnormal
FROM
Yamibuy_Master.xysc_order_info
WHERE
abnormal = !4
AND order_status = 1
AND shipping_status = 0
AND pay_status = 0
AND warehouse_number = 002
) AS A ON oi.order_id = A.order_id
SET oi.pay_status = 2 , oi.abnormal = 4;