index.php insert into de_name( SELECT *FROM de_userWHERE username IN ( SELECT username FROM de_user GROUP BY username HAVING count(*) 1 )AND id not IN ( SELECT min(id) FROM de_user GROUP BY username HAVING count(*) 1))delete a.* from tg_wik
insert into de_name( SELECT * FROM de_user WHERE username IN ( SELECT username FROM de_user GROUP BY username HAVING count(*) > 1 ) AND id not IN ( SELECT min(id) FROM de_user GROUP BY username HAVING count(*) > 1 ) ) delete a.* from tg_wiki_products a, tg_products b where a.product_id = b.product_id ;