我有以下查询显示重复的行:
SELECT ID, user_login, wp_users.user_email FROM wp_users
INNER JOIN (SELECT wp_users.user_email FROM wp_users
GROUP BY wp_users.user_email HAVING count(ID) > 1) dup ON wp_users.user_email = dup.user_email
我只能找到删除其中一个的查询,而不是只删除其中一个(比如ID最高的那个)。
有什么想法吗?
答案 0 :(得分:1)
请尝试使用此sql删除重复的行:
delete from users where id not in (select min(id) from users group by user_email)
答案 1 :(得分:0)
DELETE FROM
table_name A
WHERE a.rowid > ANY ( SELECT B.rowid
FROM table_name B
WHERE A.col1 = B.col1 AND
A.col2 = B.col2
);
我想这会起作用