Delete from co_jobinformation C
where C.name in (select Cc.name from Co_jobinformation cc GROUP BY Cc.name have count (cc.name) > 1)
and rowID not in (select min (rowid) from Co_jobinformation e Group by E.name have Count (e.name) >1)
Previously in the Oracle database can delete duplicate data and can keep a unique data, but the same MySQL does not,
MySQL has a feature, to modify the table, delete the operation, the subquery can not be the same as the outer query table, so the addition of a select can be
DELETE tt.*
From T_user TT--This is the table of operations
WHERE Tt.username--This is the duplicate user name data
In (
SELECT Cc.username
From (
SELECT b.*
From T_user b
) cc
GROUP by Cc.username
Having COUNT (cc.username) >1
)
and Tt.id--here is the smallest reservation ID, it should be easier to read.
Not IN (
SELECT MIN (e.id)
From (
SELECT ee.*
From T_user ee) E
GROUP by E.username
Having COUNT (e.username) >1)
)
)
I write a little ugly, but I want the results achieved, that is, the above sub-query inside the table for select query, but also master left high-quality SQL, thank you!
MySQL Delete duplicate data