mysql去重时报错You can’t specify target table for update in FROM clause
不能在同一表中查询的数据作为同一表的更新数据。
mysql需嵌套一层 让数据库认为你不是查同一表的数据作为同一表的更新数据
delete from t_location_card
where id in
(select a.id from
(
select id from t_location_card
where num in (select num from t_location_card group by num having count(num) > 1)
and id not in (select max(id) from t_location_card group by num having count(num)>1)
) a
)