一、根据projectNumber和deviceNumber字段找到重复记录
SELECT * from (SELECT *, CONCAT(projectNumber,deviceNumber) as nameAndCode from em_camerainfo) t WHERE t.nameAndCode in
(
SELECT nameAndCode from (SELECT CONCAT(projectNumber,deviceNumber) as nameAndCode from em_camerainfo) tt GROUP BY nameAndCode HAVING count(nameAndCode) > 1
)
2、删除重复记录,只保留id字段值最大的记录
DELETE from em_camerainfo WHERE id not in
(
SELECT maxid from (SELECT MAX(id) as maxid, CONCAT(projectNumber,deviceNumber) as nameAndCode from em_camerainfo GROUP BY nameAndCode) t
)