Possible Duplicate:
Mysql Duplicate Rows ( Duplicate detected using 2 columns )
在 MySQL 数据库中,我有很多行。例如:
id | title | time | domain
32 title1 12:30 domain1.com
33 title1 12:30 domain2.com
34 title2 14:20 domain1.com
35 title3 14:30 domain2.com
36 title1 12:30 domain55.com
我如何能够根据仅标题和时间从数据库中选择行?重复的域或 ID 无关紧要,只关心其他两个字段。
我希望能够检索第 32、33 和 36 行,因为它们具有相同的标题和相同的时间。
我不想输入标题或时间,我希望查询返回在这两个字段上找到“重复”匹配项的所有字段,无论是两个字段还是 50 个字段。这样我可以浏览并编辑或删除一些重复项。
最佳答案
这就是你想要的
SELECT title, time
FROM table
GROUP BY title, time
HAVING count(*) > 1
关于mysql - 如何根据 MySQL 中的多个字段查找重复行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12691327/