可以先找出重复的记录,用那个牵套的sql语句速度会有影响,用group by和having 例如:select NO,COUNT(NO) from table group by NO having count(NO)>1
delete atable where exists(select * from atable t where t.id <> atable.id and t.col01 = atable.col01 and t.col02 = atable.col02 ...)
delete from a a where a.rowid!=(select max(rowid) from a b where a.bm=b.bm and a.mc=b.mc);
删除重复列的方法(1) DELETE FROM table_name A WHERE ROWID > ( SELECT min(rowid) FROM table_name B WHERE A.key_values = B.key_values); (2) create table table2 as select distinct * from table1; drop table1; rename table2 to table1; (3) Delete from mytable where rowid not in( select max(rowid) from mytable group by column_name ); (4) delete from mytable t1 where exists (select 'x' from my_table t2 where t2.key_value1 = t1.key_value1 and t2.key_value2 = t1.key_value2 ... and t2.rowid > t1.rowid);
如果没有我觉得Lastdrop(空杯)就很好
可以找出重復數據。
delete from table a where rowid>(select min(rowid) from table b where a.usrid=b.usrid);
select * from table where rowid not in (select min(rowid) from table group by column1...);
例如:select NO,COUNT(NO) from table group by NO having count(NO)>1
where exists(select * from atable t
where t.id <> atable.id
and t.col01 = atable.col01
and t.col02 = atable.col02
...)
SELECT min(rowid) FROM table_name B
WHERE A.key_values = B.key_values);
(2) create table table2 as select distinct * from table1;
drop table1;
rename table2 to table1;
(3) Delete from mytable where rowid not in(
select max(rowid) from mytable
group by column_name );
(4) delete from mytable t1
where exists (select 'x' from my_table t2
where t2.key_value1 = t1.key_value1
and t2.key_value2 = t1.key_value2
...
and t2.rowid > t1.rowid);