删除mysql 重复数据

来源:互联网 发布:海康威视 网络不可达 编辑:程序博客网 时间:2024/05/19 12:13


delete t1 as t1 from terminal_alarm_list as t1,

(select distinct min(alarm_id) as alarm_id,terminal_id,type_id 
from terminal_alarm_list where  type_id=41 and isok=1 
group by terminal_id having count(1)>1 ) as t2 
where t1.terminal_id = t2.terminal_id and t1.type_id =41 and 
t1.alarm_id <> t2.alarm_id
原创粉丝点击