删除重复数据,保留重复数据中最小id所在行的数据

delete from basis_family

where

number in (select snumber from (select number as snumber from basis_family group by number having count(number) > 1) a)

and

id not in (select sid from (select min(id) as sid from basis_family group by number having count(number) > 1 ) b)

你可能感兴趣的:(删除重复数据,保留重复数据中最小id所在行的数据)