mysql 查询重复数据

当我们的数据库中存在脏重复数据时 就不得不去查询存在的脏重复数据是那些 有多少 那么这时候就需要这个语句

> select * from 表名 WHERE 字段名 in (select 字段名 from 表名 group by 字段名 having count(字段名) > 1)
eg:
select * from user WHERE cId in (select cId from user group by cId having count(cId) > 1)

小知识点

group by 后面是不可以跟where的

猜你喜欢

转载自blog.csdn.net/program_blackcat/article/details/80196343