现象:在mysql中同一语句中执行update语句部分值是select同一表出来的,就会报You can't specify target table 'xxxxx' for update in FROM clause错误,意思是在同一语句中不能先select出同一表中的某些值,再update到这个表中,如下语句
update xxl_job_info set child_jobid =(select id from xxl_job_info where executor_handler ='accountCutDayJobHandler')where executor_handler ='orderReportGenerateJobHandler';
原因:Mysql不支持这种写法,在oracle是可以的。
解决方法:Mysql的正确写法是把select出来的结果放到中间表再select一次就行了,如下
update xxl_job_info set child_jobid =(select a.id from(select id from xxl_job_info where executor_handler ='accountCutDayJobHandler') a)where executor_handler ='orderReportGenerateJobHandler';
MySQL 8 ERROR 1093 (HY000): You can't specify target table 'xxxxx' for update in FROM clause
Mysql版本:8.0.17现象:在mysql中同一语句中执行update语句部分值是select同一表出来的,就会报You can't specify target table 'xxxxx' for update in FROM clause错误,意思是在同一语句中不能先select出同一表中的某些值,再update到这个表中,如下语句update xxl_job_info set chi...