I have a table which has multiple RFID records and each record has a column called time and what I want is deleting duplicate RFID recods except one which has max time.
table name is attendance_images(id,RFID,time,year,month,day) and my query is as below:
DELETE t FROM attendance_images AS t LEFT JOIN (
SELECT max( t1.time ) AS time
FROM attendance_images AS t1
WHERE t1.year=2016
AND t1.month=8
AND t1.day=4
AND t1.time < 120000
GROUP BY t1.RFID
) keep ON t.time = keep.time
WHERE keep.time IS NULL
AND t.year =2016
AND t.month =8
AND t.day =4
AND t.time < 120000
The query effect is (0 rows deleted. (Query took 0.0034 sec)
) but the table has duplicate records according condition.
Please help to fix this issue.