mysql删除重复记录的例子
程序员文章站
2022-07-14 20:17:01
...
SELECT * FROM ip_one WHERE id NOT IN ( SELECT * FROM (SELECT MIN(id) FROM ip_one GROUP BY user_id )a )
DELETE FROM ip_one WHERE id NOT IN ( SELECT * FROM (SELECT MIN(id) FROM ip_one GROUP BY user_id )a )
mysql 5.1.4中SELECT * FROM (SELECT MIN(id) FROM ip_one GROUP BY user_id )a 别名是必须的,否则会报错。
上一篇: linux一个用户添加到多个组里面的方法