最新消息:本站所有跳转向bbs.ykit.cn的附件将全面停止,附件已转移到https://www.qingsj.com

Mysql重复数据去重保留一条数据

Mysql 有客 438浏览
delete from poi where id in 
(
select id from (
select * from poi where poi_id in
(
select poi_id from poi group by poi_id having count(poi_id) >1  
)
and id not in (select min(id) from poi group by poi_id having count(poi_id)>1)
) a
);

poi表,poi_id需要去重的字段,保留最小ID

转载请注明:有客帮 » Mysql重复数据去重保留一条数据