delete tt from tt inner join (select id,name from tt group by id,name having count(*)>1) b on tt.name=b.name and tt.id=b.iddelete tt from tt inner join (select name from tt group by name having count(*)>1) b on tt.name=b.name
是用SQL语句删除么? 用存储过程行不行?
只有name重复怎么写?delete a from table1 a left join (select id from table1 group by name) b on a.id=b.id where b.id is null
id name都重复怎么写? 表中没有主键,无解。只能变通的方法,重新生成一张新表,然后将旧表中数据清空,再把新表中数据倒回到旧表。create table2 as select distinct id,name from table1; delete from table1; insert into table1 select * from table2;
只有name重复怎么写?
两个问题
on tt.name=b.name and tt.id=b.iddelete tt from tt inner join (select name from tt group by name having count(*)>1) b
on tt.name=b.name
表中没有主键,无解。只能变通的方法,重新生成一张新表,然后将旧表中数据清空,再把新表中数据倒回到旧表。create table2 as select distinct id,name from table1;
delete from table1;
insert into table1 select * from table2;