我想从我的数据库中删除重复的评论
Delete FROM `comments` WHERE id IN
(
SELECT id
FROM comments
GROUP BY
COMMENT , course_id
HAVING COUNT( * ) >1
)
我收到错误#1093 -
您无法在FROM子句中为更新指定目标表'comments'。
如何修改我的查询才能正常工作
答案 0 :(得分:1)
尝试别名子查询:
Delete FROM `comments` WHERE id IN
(
select * from (
SELECT id
FROM comments GROUP BY COMMENT , course_id
HAVING COUNT( * ) >1
) as comm
)