#1093 - 您无法在FROM子句中为更新指定目标表“注释”

时间:2016-02-09 11:39:55

标签: mysql duplicates

我想从我的数据库中删除重复的评论

Delete FROM `comments` WHERE id IN 
(
  SELECT id
  FROM comments
  GROUP BY 
  COMMENT , course_id
  HAVING COUNT( * ) >1
)

我收到错误#1093 -

  

您无法在FROM子句中为更新指定目标表'comments'。

如何修改我的查询才能正常工作

1 个答案:

答案 0 :(得分:1)

尝试别名子查询:

Delete FROM `comments` WHERE id IN 
(
  select * from (
      SELECT id
      FROM comments GROUP BY  COMMENT , course_id
      HAVING COUNT( * ) >1
  ) as comm
)