修正现在的表添加一个唯一的标识先按条件分组,统计两个关键的内容数量:大于1的时需要删除的max或min的标识: 用于删除得行标识delete from 表where id in(slect id ,count(*) ,max(id) from 表 groupby id having count(*)>1)如果有大于2的重复记录,需要在写循环删除
有2个办法1.找出一份不重复的表,导入到临时表,把原先的表数据删除,在把临时表的数据导回去,这个适合没有ID字段的表,语句:找出唯一数据,把重复去掉并存入中转表:select distinct * into table(中转表名称) from tb(原表) 删除原
delete from 表名 where id not in (select min(id),food,name from 表名 group by food,name)
--查出重复的数据,通过制distinct去重,保存到临时表 select distinct * into #aaa from 表 where id in (select id from 表 group by having count(id) > 1)--删除实表中的重复2113数据 delete from 表 where id in (select id from 表 group by having count(
用distinct去掉重复项你的意思是这样吗?select distinct 你要得到的字段名称 from 表
select distinct 重复字段名称 FROM 表
第一,查询出你需要删除的的数据时间段第二,删除这就是个嵌套语句.
delete from T where T.rowid!=(select max(rowid) from T t where student.A=t.A and student.B=t.B and student.C=t.C);
如果所用的数据库是 Microsoft SQL Server的话,对于这种所有字段完全相同的数据记录,是无法做到只删除一条的,因为数据库无法定位这些相同的记录中的某一条!所以,如果执行删除的话,只有两种可能(具体看你所使用的SQL查询工具
通过 group by 查询sql数据库中表中重复的数据 如:查询姓名相同的学生姓名 select s_name from s_table group by s_name having count(1)>1至于如何选其中一个进行更新操作,你可以通过 select sno,a.s_name //获得学号和姓名from s_table