在Mysql表中记录重复记录? [英] Count duplicates records in Mysql table?
本文介绍了在Mysql表中记录重复记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
tbl
id名称
1 AAA
2 BBB
3 BBB
4 BBB
5 AAA
6 CCC
从tbl
组中选择count(name)c从名称具有c> 1
返回此结果的查询:
AAA(2)重复
BBB(3)重复
CCC(1)不重复
与AAA和BBB重复的名称。最终结果,我想要的是这个重复记录的数量。
结果应该是这样的:
总重复的产品( 2 )
解决方案
SELECT count(*)AS duplicate_count
FROM b $ b SELECT name FROM tbl
GROUP BY name HAVING COUNT(name)> 1
)AS t
I have table with, folowing structure.
tbl
id name
1 AAA
2 BBB
3 BBB
4 BBB
5 AAA
6 CCC
select count(name) c from tbl
group by name having c >1
The query returning this result:
AAA(2) duplicate
BBB(3) duplicate
CCC(1) not duplicate
The names who are duplicates as AAA and BBB. The final result, who I want is count of this duplicate records.
Result should be like this: Total duplicate products (2)
解决方案
SELECT count(*) AS duplicate_count
FROM (
SELECT name FROM tbl
GROUP BY name HAVING COUNT(name) > 1
) AS t
这篇关于在Mysql表中记录重复记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文