UPDATE t_finance_certify_copy c SET c.biz_type=2,c.sub_biz_type=18
WHERE c.finance_certify_id IN(
SELECT finance_certify_id FROM t_finance_certify_copy WHERE biz_type=11
)
执行语句报错:
[Err] 1093 - You can't specify target table 'c' for update in FROM clause
Oracle这样写诗没有问题的,但是MySQL数据库里update时,更新的表不能在set和where中用于子查询。
上述sql语句可以改成:
UPDATE t_finance_certify_copy c SET c.biz_type=2,c.sub_biz_type=18
WHERE c.finance_certify_id IN(
SELECT finance_certify_id FROM (SELECT finance_certify_id FROM t_finance_certify_copy WHERE biz_type=11) a
)