sql语句:
delete from t_user_point where user_point_id not in (select max(user_point_id) from t_user_point group by user_id);
not in的效率可能会低些,但因为是直接操作数据库,所以这并不重要.这个句子还是非常的简单有效的.
而删重复数据前,可以先查一下多余数据的情况:
select count(user_point_id),user_id from t_user_point group by user_id;
直接select distinct into到另外新的一张表里然后drop掉本张表就ok了
查出所有不重复记录重新建个表
create table tablename1
as
select distinct * from tablename
truncate掉原来表,把数据导回去。
group by? 你去查查手册用法