删除重复数据

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;
相关推荐
v***91302 小时前
【MySQL】JDBC的连接
数据库·mysql
j***51892 小时前
Redis 安装及配置教程(Windows)【安装】
数据库·windows·redis
A***F1575 小时前
Redis开启远程访问
数据库·redis·缓存
v***44675 小时前
【MySQL — 数据库基础】深入理解数据库服务与数据库关系、MySQL连接创建、客户端工具及架构解析
数据库·mysql·架构
v***59835 小时前
Django视图与URLs路由详解
数据库·django·sqlite
i***48615 小时前
MySQL中的GROUP_CONCAT()函数详解与实战应用
数据库·mysql
K***43065 小时前
MySQL中的TRUNCATE TABLE命令
数据库·mysql
tyatyatya5 小时前
MATLAB图形标注教程:title()/xlabel()/ylabel()/legend()/grid on全解析
数据库·matlab·信息可视化
e***95645 小时前
DBeaver连接本地MySQL、创建数据库表的基础操作
数据库·mysql
左灯右行的爱情5 小时前
MySQL高并发-主从架构
数据库·mysql·架构