select 字段1,字段2,count(*) from 表名 group by 字段1,字段2 having count(*) > 1
delete from 表名 a where 字段1,字段2 in(select 字段1,字段2,count(*) from 表名 group by 字段1,字段2 having count(*) > 1)
create table 臨時(shí)表 as(select 字段1,字段2,count(*) from 表名 group by 字段1,字段2 having count(*) > 1)
delete from 表名 a where 字段1,字段2 in (select 字段1,字段2 from 臨時(shí)表);
select a.rowid,a.* from 表名 a where a.rowid != ( select max(b.rowid) from 表名 b where a.字段1 = b.字段1 and a.字段2 = b.字段2 )
delete from 表名 a where a.rowid != ( select max(b.rowid) from 表名 b where a.字段1 = b.字段1 and a.字段2 = b.字段2 )
create table 臨時(shí)表 as select a.字段1,a.字段2,max(a.rowid) dataid from 正式表 a group by a.字段1,a.字段2; delete from 表名 a where a.rowid != ( select b.dataid from 臨時(shí)表 b where a.字段1 = b.字段1 and a.字段2 = b.字段2 ); commit;
select distinct * from 表名
create table 臨時(shí)表 as (select distinct * from 表名); drop table 正式表; insert into 正式表 (select * from 臨時(shí)表); drop table 臨時(shí)表;
insert into t_table_bakselect distinct * from t_table;
新聞熱點(diǎn)
疑難解答
圖片精選