delete from table_name as ta where ta.唯一键 <> ( select max(tb.唯一键) from table_name as tb where ta.判断重复的列 = tb.判断重复的列);
例子
delete from wr_yr_sync_log as wylog where wylog.log_id <> (select max(wylog2.log_id) from wr_yr_sync_log as wylog2 where wylog.yr_cuid = wylog2.yr_cuid);
如果station_id为uuid类型,查询出重复数据:
select count(*) from wr_space_station as ss where concat(ss.station_id,'') <> (select min(concat(ss2.station_id,'')) from wr_space_station as ss2 where ss.station_name = ss2.station_name);
如果station_id为uuid类型,删除重复数据:
delete from wr_space_station as ss where concat(ss.station_id,'') <> (select min(concat(ss2.station_id,'')) from wr_space_station as ss2 where ss.station_name = ss2.station_name);