id列重复
select count(id),name
from table
group by id having count(id)>1
id列和name列都重复
select count(id),name
from table
group by id,name having count(id)>1
本文介绍如何使用SQL查询数据库中ID及名称重复的数据。首先展示如何找出ID重复的记录,然后进一步展示如何查找ID和名称同时重复的情况。这些SQL查询对于数据清洗和验证数据一致性非常有用。
id列重复
select count(id),name
from table
group by id having count(id)>1
id列和name列都重复
select count(id),name
from table
group by id,name having count(id)>1

被折叠的 条评论
为什么被折叠?