日常Exception(十六):You cant specify target table xxx for update in FROM clause

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)

在要刪除的語句上,再加一個查詢語句嵌套即可!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章