select * from tablename where username not in (select username from tablename where count(username)>=2)
union select d.* from tablename as d,(select username,min(id) as id1 from tablename as a,(select username from tablename where count(username)>=2) as b where a.username=b.username group username) as c where c.username=d.username and d.id=c.id1
得到值
直接删掉可以这样做
delect d.* from tablename as d,(select username,min(id) as id1 from tablename as a,(select username from tablename where count(username)>=2) as b where a.username=b.username group username) as c where c.username=d.username and d.id!=c.id1