Mysql update in报错 [Err] 1093 - You can't specify target table 'company_info' for update in FROM clause
Mysql update in报错 解决方案:
[Err] 1093 - You can't specify target table 'company_info' for update in FROM clause
意思是不能在同一语句中更新select出的同一张表元组的属性值
解决方法:将select出的结果通过中间表再select一遍即可。
错误sql:
update company_info set email = 'ttt@163.com' where id in (select t.id from company_info t where t.id<3)
修改后可执行的sql:
update company_info set email = 'ttt@163.com' where id in (select a.id from (select t.id from company_info t where t.id<3)a )