50,523
社区成员
发帖
与我相关
我的任务
分享
SQL语句
select * from tableName where tableName.id in ( select max (tableName.id) from tableName group by tableName.name having count (tableName.id) > 1 )
SQL>create table test as select distinct * from cz;
(建一个临时表test用来存放重复的记录)
SQL>truncate table cz; (清空cz表的数据,但保留cz表的结构)
SQL>insert into cz select * from test;
(再将临时表test里的内容反插回来)
delete from t_table where (name,price,date) in (select name,price,date
from t_table group by name,price,date having count(*)>1)
and rowid not in (select min(rowid) from t_table
group by name,price,date having count(*)>1);
delete from t_table where (name,price,date) in (select name,price,date from t_table group by name,price,date having count(*)>1) and rowid not in (select min(rowid) from t_table group by name,price,date having count(*)>1);
delete from tablename where id in(select id from (select count(*),max(id) as id from tablename groupfor name,price,date)as temp)