DELETE c1 FROM contacts c1
INNER JOIN contacts c2
WHERE
c1.id > c2.id AND
c1.email = c2.email;
DELETE FROM CONTACTS
WHERE ID NOT IN
(SELECT *
FROM (SELECT max(ID)
FROM CONTACTS
GROUP BY EMAIL) t);
-- ⇓ Test it ⇓ (Fiddle source link)
DELETE FROM FriendsData WHERE fID
NOT IN ( SELECT fID FROM FriendsData
GROUP BY UserID, FriendsUserID, IsSpecial, CreatedBy)
DELETE
FROM
`tbl_job_title`
WHERE id NOT IN
(SELECT
*
FROM
(SELECT
MAX(id)
FROM
`tbl_job_title`
GROUP BY NAME) tbl)
delete test
from test
inner join (
select max(id) as lastId, email
from test
group by email
having count(*) > 1) duplic on duplic.email = test.email
where test.id < duplic.lastId;
DELETE `yellow_page_content`
from `yellow_page_content`
inner join (
select max(`id`) as lastId, `code`
from `yellow_page_content`
group by `code`
having count(*) > 1) duplic on duplic.code = yellow_page_content.code
where yellow_page_content.id < duplic.lastId;
DELETE FROM NAMES
WHERE id NOT IN (SELECT *
FROM (SELECT MIN(n.id)
FROM NAMES n
GROUP BY n.name) x)
DELETE c1 FROM contacts c1
INNER JOIN contacts c2
WHERE
c1.id > c2.id AND
c1.email = c2.email;
Code language: SQL (Structured Query Language) (sql)