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)