mysql查询出所有重复的记录

懒散的作者
2020-11-09 / 0 评论 / 363 阅读 / 正在检测是否收录...

查找出所有的重复数据(list)

SELECT * FROM 表名 WHERE 关键词 IN (SELECT message_no FROM 表名 GROUP BY 关键词 HAVING COUNT(关键词)>1)
SELECT * FROM news_log WHERE message_no IN (SELECT message_no FROM news_log GROUP BY message_no HAVING COUNT(message_no)>1)

其中的message_no 是关键词,查询这个表是否有多个message_no的记录。并且group by message_no

查看重复数据的条数(count)

SELECT 关键词,COUNT() FROM 表名 GROUP BY 关键词 HAVING COUNT() > 1
SELECT message_no,COUNT(*) FROM news_log GROUP BY message_no HAVING COUNT(*) > 1

以message_no 去查询是否有多条

0

评论 (0)

取消