我有一个注释表,其结构如下:
id, name, email, comment
我有很多重复的评论,名字和电子邮件都一样。我需要删除它们,有人可以建议我如何使用一个查询来实现此目标吗?
谢谢
DELETE FROM comments c1
WHERE EXISTS ( SELECT * FROM comments c2 WHERE c2.id <> c1.id AND c2.name = c1.name AND c2.email = c1.email AND c2.comment = c1.comment ) AND c1.id <> ( SELECT MIN(c2.id) FROM comments c2 WHERE c2.name = c1.name AND c2.email = c1.email AND c2.comment = c1.comment )