
框起来的部分时重复的记录,如何使用sql语句删除任意一条重复的记录
设表名为:test_user
DELETE FROM test_user WHERE(type_user,user_u_id,gtrevuser_id)
IN(SELECT type_user,user_u_id,gtrevuser_id FROM(SELECT type_user,user_u_id,gtrevuser_id FROM test_user GROUP BY type_user,user_u_id,gtrevuser_id HAVING count() > 1) AS A)
AND id NOT IN(SELECT id FROM(SELECT min(id) AS id FROM test_user GROUP BY type_user,user_u_id,gtrevuser_id HAVING count()>1) AS B)
DELETE FROM test_user WHERE(type_user,user_u_id,gtrevuser_id)
IN(SELECT type_user,user_u_id,gtrevuser_id FROM(SELECT type_user,user_u_id,gtrevuser_id FROM test_user GROUP BY type_user,user_u_id,gtrevuser_id HAVING count() > 1) AS A)
AND id NOT IN(SELECT id FROM(SELECT min(id) AS id FROM test_user GROUP BY type_user,user_u_id,gtrevuser_id HAVING count()>1) AS B)