• 使用mysql,sql语言删除冗余信息


    这是表,我们需要操作的就是删除除了学号不同,其它信息都相同的冗余信息

    思路:删除表格class3中的冗余的stu_id信息,那么接下来我们应该去筛选哪些stu_id信息是冗余的,

    此时我们想到的就是利用group by语句进行分组,即select min(stu_id) from class3 group by name,project,stu_id

    这条语句,便帮我们去除掉了冗余的stu_id信息。即用到min()函数,和group by 便可得到我们想要的结果!

    此时我们就可执行语句:

    delete from class3 where stu_id not in (select min(stu_id) from class3 group by name,project,stu_id)

    但我们使用mysql数据库执行该语言的时候,报错,是因为mysql自身的bug! 可对以上语句进行修改:

    delete from class3 where stu_id not in (select b from(select min(stu_id)  as b from class3 group by name,project,stu_id))b

  • 相关阅读:
    http状态码
    闭包
    节流和防抖
    继承方式
    array和object对比
    排序算法
    算法题
    汇编 asm 笔记
    FFMPEG 内部 YUV444P016 -> P010
    FFMPEG 内部 YUV444p16LE-> P016LE
  • 原文地址:https://www.cnblogs.com/ConnorShip/p/9950864.html
Copyright © 2020-2023  润新知