delete from user where id not in ( select * from ( select min(id) from user group by username,email ) ) as tmp;