///
SELECT serverip FROM servers GROUP BY serverip HAVING COUNT(*) > 1;
///
///
SELECT max(id) as id, serverip FROM servers WHERE serverip in
(
SELECT serverip FROM servers GROUP BY serverip HAVING COUNT(*) > 1
) GROUP BY serverip;
///
///
DELETE servers FROM servers
INNER JOIN (
SELECT max(id) as id, serverip FROM servers WHERE serverip in
(
SELECT serverip FROM servers GROUP BY serverip HAVING COUNT(*) > 1
) GROUP BY serverip
) duplic on duplic.serverip = servers.serverip
WHERE servers.id < duplic.id;
///
Categories: MySql language
74 Comments