I have a MySQL table with many duplicate rows. How can I go about finding the id's and deleting them. I need to leave the first lead_id and delete the any other duplicates.
So in this sample I would need to find the duplicate email values and delete all the rows. IE. delete all the rows with a lead_id of 40944 and keep all the 40943.
id      |   lead_id     | form  |field_number   |   value
--------+---------------+-------+---------------+----------------------
537618  |   40943       |1      | 3.3           |   Mike
537622  |   40943       |1      | 4.3           |   Mesa
537623  |   40943       |1      | 4.4           |   AZ
537624  |   40943       |1      | 4.5           |   85210
537625  |   40943       |1      | 4.6           |   United States
537626  |   40943       |1      | 5             |   mike@email.com
537627  |   40943       |1      | 6             |   (555) 555-5555
537628  |   40943       |1      | 19            |   JM-SL-I4CLR,JM-FM-I5CLR
537629  |   40943       |1      | 12            |   2015-10-01
547618  |   40944       |1      | 3.3           |   Mike
547622  |   40944       |1      | 4.3           |   Mesa
547623  |   40944       |1      | 4.4           |   AZ
547624  |   40944       |1      | 4.5           |   85210
547625  |   40944       |1      | 4.6           |   United States
547626  |   40944       |1      | 5             |   mike@email.com
547627  |   40944       |1      | 6             |   (555) 555-5555
547628  |   40944       |1      | 19            |   JM-SL-I4CLR,JM-FM-I5CLR
547629  |   40944       |1      | 12            |   2015-10-01
I have tried :
SELECT `value`, count(*) 
 FROM `lead_detail` 
 WHERE `field_number` = 5 
 GROUP BY `value` 
 HAVING count(*) > 1
Results
value          |    count(*)
---------------+------------------
mike@email.com |    2
Just not sure how to delete the rows?
 
     
     
     
    