CREATE TABLE tmp_voucher SELECT a.voucher_id FROM voucher a, voucher_action b WHERE a.stock_id = 50 AND a.status_id != 40 AND a.voucher_id = b.voucher_id AND b.action_id = 60 GROUP BY a.voucher_id UPDATE voucher a, tmp_voucher b SET a.stock_id = 60 WHERE a.voucher_id = b.voucher_id drop table tmp_voucher;
使用以上方法解决,
因为mysql不能直接update查询子句内的字段否则会报错“you can't specify target table 'xxxx' for update in from CLAUSE”