• 后台 清空冗余数据



    删除重复记录
    Delete from tablename where id not in (select max(id) from tablename group by col1,col2,...)
    两张关联表,删除主表中已经在副表中没有的信息
    delete from table1 where not exists ( select * from table2 where table1.field1=table2.field1 )

    delete from sns_message where not exists ( select * from sns_user where sns_user.uid=sns_message.to_uid);

    找出数据库中有某字段的所有表;
    SELECT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA ='ipiao20' and COLUMN_NAME ='uid'


    查询表中重复记录
    select * from sns_friend a
    where (a.`uid`,a.`friend_uid`) in (select `uid`,`friend_uid`from sns_friend group by `uid`,`friend_uid`having count(*) > 1)
    and `friend_id`not in (select min(`friend_id`) from sns_friend group by `uid`,`friend_uid`having count(*)>1)


    delete from sns_friend as a
    where ((a.`uid`,a.`friend_uid`) in (select `uid`,`friend_uid`from sns_friend group by `uid`,`friend_uid`having count(*) > 1))
    and (`friend_id`not in (select min(`friend_id`) from sns_friend group by `uid`,`friend_uid`having count(*)>1))


    delete from sns_friend a where ((a.`uid`,a.`friend_uid`) in

    and `friend_id` not in (select min(`friend_id`) from sns_friend group by `uid`,`friend_uid` having count(*)>1)

    前望
  • 相关阅读:
    win10彻底永久关闭自动更新的方法
    kibana.yml配置
    完整记录安装elasticsearch的过程
    docker下nginx的安装
    centos7删除mysql
    21 | panic函数、recover函数以及defer语句 (上)
    07 | 数组和切片
    SNAPSHOT包上传nexus成功,下载失败
    extract method(提炼函数)
    枚举中不要再出现数字了
  • 原文地址:https://www.cnblogs.com/ybbqg/p/2480847.html
Copyright © 2020-2023  润新知