delete from test1 where (id,name )in (select * from ( select id,name from test1 group by id,name having (count(*)>1) ) a) and num not in(select * from ( select min(num) from test1 group by id,name having (count(*)>1) ) b); create table d as select * from t1;