如何刪除重復(fù)數(shù)據(jù), 只保留一條
drop table if exists temp_dm_patientinfo_id; create table temp_dm_patientinfo_id as select record_id, -- 重復(fù)鍵 max(id) max_id from dm_patientinfo -- 重復(fù)記錄所在表 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;
每天進(jìn)步一點(diǎn)點(diǎn)
浙公網(wǎng)安備 33010602011771號(hào)