I have written a query to find the duplicate rows in a table. It outputs duplicate pairs (e.g. row: 1,2
after that you enounter row: 2,1
)
SELECT m1.ID, m2.ID
FROM AccessLog_Manual m1
INNER JOIN AccessLog_Manual m2 ON
m1.ACCESS = m2.ACCESS AND
m1.EMPLOYEEID = m2.EMPLOYEEID AND
m1.LOGDATETIME = m2.LOGDATETIME AND
m1.MORPHOACCESSID = m2.MORPHOACCESSID AND
m1.ID <> m2.ID
ORDER BY m1.ID
Now I want to use this query in a delete statement, such that removing only one row of pairs. (i.e. for example row 1,2
and row 2,1
, only delete 1
and let 2
non-deleted)