在执行sql:
delete from emp where id in (select id from emp where cdate<'2018-02-02')
时报出以下异常:
### The error occurred while setting parameters ### SQL: delete from emp where id in (select id from emp where cdate<?) ### Cause: java.sql.SQLException: You can't specify target table 'emp' for update in FROM clause INFO [main] - Time elapsed:10s.
错误原因:不能先将select出表中的某些值,再update这个表
解决方案:将SQL修改如下:
delete from emp where id in (select id from (select id from emp where cdate<'2018-02-02') as tb)
--END-- 2019年10月14日10:17:27