现有一张表如上:content列有一个重复的数据,我想去掉一条(不考虑其他列),显示成下面的结果
select * from t_xf_care_education where id in (select min(id) from t_xf_care_education group by content);
格式:
查找不重复列:
select * from 表名 where 列1 in (select min(列1) from 表名 group by 列3)
其中 列1最好是不会重复的主键(自增,类型int,bigint等)。
如果是uuid生成方式生成的主键,我们考虑其他实现方式,或寻找别列。
删除重复数据:(慎用)
delete 表名 where 列1 not in (select min(列1) from 表名 group by 列3)