1、查询表中重复数据(单字段)
Select * From 表 Where 字段  1 In (Select 字段  1 From 表 Group By 字段  1 Having Count(字段1) > 1)
2、删除表中多余的重复记录,只留有rowid最小的记录(单字段) Delete From 表
Where 字段1 In (Select 字段1 From 表 Group By 字段1 Having Count(字段1) > 1) And
Rowid Not In (Select Min(Rowid) From 表 Group By 字段1 Having Count(字段1) > 1)
sql语句怎么查询两张表的数据
3、查表中多余的重复记录(多个字段)
Select * From 表 a Where (a.字段1, a.字段2) In (Select 字段1, 字段2 From 表 Group By 字段1, 字段2 Having Count(*) > 1)
4、删除表中多余的重复记录,只留有rowid最小的记录(多个字段) Delete From 表 a Where (a.字段1, a.字段2) In (Select 字段1, 字段2 From 表 Group By 字段1, 字段2 Having Count(*) > 1) And
Rowid Not In (Select Min(Rowid) From 表 Group By 字段1, 字段2 Having Count(*) >
1)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。