【日常Exception】第十六回:You cant specify target table xxx for update in FROM clause

桃扇骨 2023-02-14 10:42 122阅读 0赞

热门系列:

  • 程序人生,精彩抢先看


1.问题

今天在执行一个删除重复数据的Sql时,发生了如题的mysql异常提示:

SQL 错误 [1093] [HY000]: You can’t specify target table ‘t_chat_evaluation’ for update in FROM clause

sql如下:

DELETE from t_chat_evaluation
where s_id IN
(SELECT s_id from t_chat_evaluation group by s_id)

2.解决

DELETE from t_chat_evaluation
where s_id IN
(SELECT * from
(SELECT s_id from t_chat_evaluation group by s_id) a)

在要删除的语句上,再加一个查询语句嵌套即可!

20201028165432463.gif

发表评论

表情:
评论列表 (有 0 条评论,122人围观)

还没有评论,来说两句吧...

相关阅读