Answers for "mysql find duplicates and delete last"

SQL
4

mysql delete older duplicates

DELETE FROM CONTACTS
WHERE ID NOT IN
      (SELECT *
       FROM (SELECT max(ID)		
             FROM CONTACTS
             GROUP BY EMAIL) t);
 -- ⇓ Test it ⇓ (Fiddle source link)
Posted by: Guest on July-13-2021
0

delete all duplicate rows keep the latest except for one in mysql

DELETE 
FROM
  `tbl_job_title` 
WHERE id NOT IN 
  (SELECT 
    * 
  FROM
    (SELECT 
      MAX(id) 
    FROM
      `tbl_job_title` 
    GROUP BY NAME) tbl)
Posted by: Guest on April-26-2021

Code answers related to "mysql find duplicates and delete last"

Code answers related to "SQL"

Browse Popular Code Answers by Language