mysql:You can't specify target table 'bpm_tksign_data' for update in FROM clause
Posted 云中飞鱼
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql:You can't specify target table 'bpm_tksign_data' for update in FROM clause相关的知识,希望对你有一定的参考价值。
UPDATE bpm_tksign_data SET iscompleted = 1 WHERE actinstid = ‘10000002433415‘ AND nodeid = ‘SignTask1‘ AND iscompleted = 0 AND batch = ( SELECT max(a.batch) m FROM bpm_tksign_data a WHERE a.actinstid = ‘10000002433415‘ AND a.nodeid = ‘SignTask1‘ );
这种写法,mysql各个版本都不支持。
UPDATE bpm_tksign_data SET iscompleted = 1 WHERE actinstid = ‘10000002433415‘ AND nodeid = ‘SignTask1‘ AND iscompleted = 0 AND batch = ( SELECT max(a.batch) m FROM (SELECT * FROM bpm_tksign_data) a WHERE a.actinstid = ‘10000002433415‘ AND a.nodeid = ‘SignTask1‘ );
这种写法,mysql 5.6支持,mysql 5.7不支持。
UPDATE bpm_tksign_data SET iscompleted = 1 WHERE actinstid = ‘10000002433415‘ AND nodeid = ‘SignTask1‘ AND iscompleted = 0 AND batch = ( SELECT p.m FROM ( SELECT max(a.batch) m FROM bpm_tksign_data a WHERE a.actinstid = ‘10000002433415‘ AND a.nodeid = ‘SignTask1‘ ) p );
这种写法,mysql各个版本都可以支持。
以上是关于mysql:You can't specify target table 'bpm_tksign_data' for update in FROM clause的主要内容,如果未能解决你的问题,请参考以下文章
MySQL : You can't specify target table 'Person' for update in FROM clause
mysql中You can't specify target table for update in FROM clause
Mysql -- You can't specify target table 'address' for update in FROM clause
mysql:You can't specify target table 'bpm_tksign_data' for update in FROM clause
mysql uodate 报错 You can't specify target table '**' for update in FROM clause
mySQL: delete 语句报错 You can't specify target table 'student' for update in FROM clause(示例