I'm trying to delete some duplicated rows of my table. I'm starting by select all the duplicated rows by executing this query :
SELECT a.id as id FROM table A join table B on A.site = B.site
where A.nb_affichages = B.nb_affichages and A.nb_clics = A.nb_clics
Then i try to delete all the selected ids from the first query :
DELETE FROM table WHERE id IN ( SELECT * FROM ( SELECT a.id as id FROM table A join table B on A.site = B.site
where A.nb_affichages = B.nb_affichages and A.nb_clics = A.nb_clics) AS p )
This second query deletes all the rows selected in the first, instead I want to let one row and delete the others.
So anyone can help me to optimize this query.