DELETE FROM tb_user_attribute WHERE userId IN (SELECT a.userId FROM (SELECT aa.* FROM tb_user_attribute AS aa) AS a GROUP BY a.userId HAVING COUNT(a.userId) > 1) AND id NOT IN (SELECT MIN(b.id) FROM (SELECT bb.* FROM tb_user_attribute AS bb) AS b GROUP BY b.userId HAVING COUNT(b.userId )>1)
Mysql删除表中某字段重复记录,并保留id最新的记录
最新推荐文章于 2019-10-30 14:46:53 发布