如何删除重复数据, 只保留一条
drop table if exists temp_dm_patientinfo_id; create table temp_dm_patientinfo_id as select record_id, -- 重复键 max(id) max_id from dm_patientinfo -- 重复记录所在表 group by record_id having count(1)>1 ; delete a from dm_patientinfo a, temp_dm_patientinfo_id b where a.record_id = b.record_id and a.id < b.max_id; drop table if exists temp_dm_patientinfo_id;
每天进步一点点