删除表中重复的数据
来源:互联网 发布:神经网络算法分类 编辑:程序博客网 时间:2024/06/01 20:45
原始表,和相关数据
DROP TABLE IF EXISTS student
;
CREATE TABLE student
(
id
int(11) NOT NULL AUTO_INCREMENT,
stuName
varchar(100) DEFAULT NULL,
sexId
int(100) DEFAULT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
INSERT INTO student
VALUES (1,’张小雨’,1);
INSERT INTO student
VALUES (2,’李娜111’,1);
INSERT INTO student
VALUES (3,’马腾’,1);
INSERT INTO student
VALUES (4,’刘君然’,2);
INSERT INTO student
VALUES (6,’11’,2);
INSERT INTO student
VALUES (7,’马世国’,1);
INSERT INTO student
VALUES (8,’啦啦啦’,1);
INSERT INTO student
VALUES (9,’啦啦啦11’,1);
INSERT INTO student
VALUES (12,’按时打的’,1);
INSERT INTO student
VALUES (13,’李娜123’,2);
INSERT INTO student
VALUES (14,’123456’,2);
INSERT INTO student
VALUES (16,’啦啦啦12’,3);
INSERT INTO student
VALUES (28,’啦啦啦12’,NULL);
INSERT INTO student
VALUES (29,’啦啦啦12’,NULL);
INSERT INTO student
VALUES (30,’李娜123’,NULL);
INSERT INTO student
VALUES (31,’李娜123’,NULL);
删除其中冗余的
DELETE FROM student WHERE id NOT IN (
SELECT b.id FROM (SELECT MIN(id) id FROM student GROUP BY stuName) b
)
思路
先分组,找出组中最大或最小的id,然后把其他的删了
- 删除表中重复的数据
- 删除SQL表中重复的数据
- 删除表中重复的数据Oracle
- 删除表中重复的数据
- 删除表中重复的数据
- 删除表中重复数据的sql
- 删除表中 user_id重复的数据
- 删除表中重复的数据
- 删除表中重复数据
- 删除表中重复数据
- 删除表中重复数据
- 删除表中重复数据
- 删除表中重复数据
- 删除表中重复数据
- 数据库中删除表中重复数据的一点心得
- Mysql 查询表中重复数据和删除表中重复的数据
- 技巧:删除表中重复数据的几种方法
- 删除表中重复的数据(oracle,sql)
- Numpy(五)
- Just do it(规律+技巧+总是时间超限)
- 编写LED混杂设备驱动:静态映射,如何用Linux内核里的gpio_request(),gpio_set_value()等函数,ioctl函数
- MOOC清华《面向对象程序设计》第2章:类class的综合实验
- JAVA中Date详解
- 删除表中重复的数据
- CF-589J Cleaner Robot
- tcp三次握手原理
- AngularJS+Bootstrap3多级导航菜单
- Centos 7.3搭建LNMP环境
- Spring Cloud 快速入门esclipse快速搭建微服务框架 (一)-注册与发现
- Linux系统操作(6)———svn服务器搭建
- Maven的聚合与继承
- 服务程序调用 CreateProcessAsUser 0xC0000005访问冲突问题