mysql 用sql 语句去掉某个字段重复值数据的方法

时间:2021-11-14 14:38:21

示例代码如下:

create table tmp as select min(主键) as col1 from 去重表名 GROUP BY 去重字段;
delete
from 去重表名 where 主键 not in (select col1 from tmp);
drop table tmp;