79291098

Date: 2024-12-18 12:37:23
Score: 1
Natty:
Report link

Building on @LStarky 's answer I made snippet to remove all duplicates except the oldest (lowest ID) one.

DELETE my_table FROM my_table
  JOIN (
    SELECT MIN(id) AS calc_id, identField1, identField2
    FROM my_table
    GROUP BY identField1, identField2
    HAVING COUNT(id) > 1
    ) sub ON sub.calc_id != my_table.id 
       AND sub.identField1 = my_table.identField1
       AND sub.identField2 = my_table.identField2
Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @LStarky
  • Low reputation (0.5):
Posted by: Dragonduck