删除数据库中冗余信息

来源:互联网 发布:餐饮收银软件zkzhiyue 编辑:程序博客网 时间:2024/04/29 20:25

eg:

id  学号         姓名    课程编号  课程名称  分数

id sid            name    cno         cname     score

1 2016001   张三     0001        数学         69

2 2016002   李四     0001        数学         89

3 2016001   张三     0001        数学         69

sql:

保留冗余数据中ID最大的数据(MySQL)

delete from student  where id not in (select  a.id from (select max(id) id from student group by sid,name,cno,cname,score)a);

other (oracle ...):

delete from student where id not in (select max(id) from student group by sid,name,cno,cname,score)

0 0
原创粉丝点击