I have unique id and email fields. Emails get duplicated. I only want to keep one Email address of all the duplicates but with the latest id<
id
email
id<
Correct way is
DELETE FROM `tablename` WHERE id NOT IN ( SELECT * FROM ( SELECT MAX(id) FROM tablename GROUP BY name ) )