删除重复数据

sql 复制代码
delete iot_instruction
from 
iot_instruction,
(
	SELECT
   min(id) id,
	 GROUP_CONCAT(id) as ids,
   command,
	 instruction_type,
	 protocol_id
  FROM
   iot_instruction
  GROUP BY
   command,instruction_type,protocol_id
  HAVING
   count(*) > 1
) t2
where iot_instruction.command = t2.command and iot_instruction.protocol_id = t2.protocol_id
and iot_instruction.instruction_type= t2.instruction_type and iot_instruction.id>t2.id;
相关推荐
怣5012 分钟前
MySQL聚合函数在查询中的五大核心应用
数据库·mysql
2301_822363601 小时前
使用Pandas进行数据分析:从数据清洗到可视化
jvm·数据库·python
Leo.yuan1 小时前
经营分析会,该讲些什么?
大数据·数据库·数据分析
云飞扬1 小时前
浅谈数据访问层
数据库·bpm·数据库访问层
Amarantine、沐风倩✨2 小时前
一次线上性能事故的处理复盘:从 SQL 到扩容的工程化思路
java·数据库·sql·oracle
电商API&Tina2 小时前
乐天平台 (Rakuten) 数据采集指南
大数据·开发语言·数据库·oracle·json
l1t2 小时前
用SQL执行累计值汇总的几种方法
数据库·sql·postgresql·duckdb
踢足球09293 小时前
寒假打卡:2026-2-3
数据库
每次学一点3 小时前
【ZeroTier自研之路】planet的组成
服务器·网络·数据库
策知道3 小时前
2026年北京政府工作报告产业指标深度解析
大数据·数据库·人工智能·搜索引擎·政务