当前位置:Gxlcms > 数据库问题 > mysql - sql报错You can't specify target table 'table_name' for update in FROM clause

mysql - sql报错You can't specify target table 'table_name' for update in FROM clause

时间:2021-07-01 10:21:17 帮助过:3人阅读

from t_person where id in (select id from t_person where name = "hello");

然而却报错: You can‘t specify target table ‘t_person‘ for update in FROM clause

以下这篇博客( https://blog.csdn.net/qq_29672495/article/details/72668008 )给出了解决方式: 将SELECT出的结果再通过中间表SELECT一遍,这样就规避了错误。

更正如下:

delete from t_person where id in (select temp.id from (select id from t_person where name = "hello") temp);

 

mysql - sql报错You can't specify target table 'table_name' for update in FROM clause

标签:筛选   sdn   bsp   upd   mysq   报错   name   from   mysql   

人气教程排行