SQL查找重复行


在表中,有的字段不是主键也不具有惟一性,可是在使用过程当中,该字段不该用重复,有的时候它恰恰重复了。因此,为了找出某个重复字段的行,使用一下SQL语句:sql

--即有:
--Select * From 表 Where 重复字段 In (Select 重复字段 From 表 Group By 重复字段 Having Count(*)>1)
--来一个具体的例子
select * from t_exterm 
where mainkeyindex in 
(select mainkeyindex from t_exterm Group By mainkeyindex Having Count(*)>1)
相关文章
相关标签/搜索