记录一次去掉重复数据 留取其他所有的最新时间的数据,效率未知。(记录意义在于一种去重逻辑,读者可以在下方留言 优化,以提高查询效率)
select * FROM `user` aa where aa.id not in(
select id from `user` bb where bb.NAMES in
(select NAMES from `user` cc group by NAMES having count(NAMES)>1)
and bb.updatetime NOT in
(select max(updatetime) from `user` dd group by NAMES having count(NAMES)>1) )