mysql快速删除重复数据,并保留id最大的一条

delete from vehicle where (VLPN,VLPNColor) in (
select t.VLPN,t.VLPNColor from (
select VLPN,VLPNColor,count(*) from vehicle group by VLPN,VLPNColor having count(*)>1
) t
) and VehicleID not in (
select t.VehicleID from (
select max(VehicleID) as VehicleID from vehicle group by VLPN,VLPNColor having count(*)>1
) t
)

猜你喜欢

转载自www.cnblogs.com/luoguixin/p/12958208.html
今日推荐