zoukankan      html  css  js  c++  java
  • Mysql两张表的关联字段不一致

    工作中遇到了一个问题,邮件系统群发失败,后来经过排查查找到了原因

    原来是因为mysql中的两张表的关联字段竟然不一致,

    表A

    mysql> desc rm_user_router;
    +------------+-------------+------+-----+---------+-------+
    | Field | Type | Null | Key | Default | Extra |
    +------------+-------------+------+-----+---------+-------+
    | CORPID | int(10) | NO | PRI | NULL | |
    | LOGINNAME | varchar(60) | NO | PRI | NULL | |
    | UIN | int(10) | NO | MUL | NULL | |
    | SPID | int(10) | NO | | NULL | |
    | MIID | int(10) | NO | | NULL | |
    | ASID | int(10) | NO | | 0 | |
    | FLAG | int(1) | NO | | 0 | |
    | REGISTERID | varchar(60) | NO | | NULL | |
    | STATUS | int(2) | NO | | NULL | |
    | RES1 | int(10) | NO | | 0 | |
    | RES2 | int(10) | NO | | 0 | |
    | CREATETIME | datetime | NO | | NULL | |
    +------------+-------------+------+-----+---------+-------+

    表B

    mysql> desc rm_group_info;
    +----------------+---------------+------+-----+---------+-------+
    | Field | Type | Null | Key | Default | Extra |
    +----------------+---------------+------+-----+---------+-------+
    | UIN | int(10) | NO | PRI | NULL | |
    | CORPID | int(10) | NO | MUL | NULL | |
    | GROUPID | varchar(60) | NO | | NULL | |
    | GROUPNAME | varchar(32) | YES | | NULL | |
    | MAXMEMBERNUM | int(10) | YES | | 0 | |
    | CURMEMBERNUM | int(10) | YES | | 0 | |
    | STATUS | int(2) | YES | | 0 | |
    | FLAG | int(2) | YES | | 0 | |
    | RECVTYPE | int(2) | YES | | 0 | |
    | CREATETIME | datetime | NO | | NULL | |
    | MODIFYTIME | datetime | NO | | NULL | |
    | WHITELIST | varchar(2000) | YES | | NULL | |
    | BLACKLIST | varchar(2000) | YES | | NULL | |
    | join_privilege | int(10) | YES | | 0 | |
    | exit_privilege | int(10) | YES | | 0 | |
    | is_auto | int(1) | NO | | 0 | |
    +----------------+---------------+------+-----+---------+-------+

    其中两张表的UIN字段竟然不一致,现在需要解决的是rm_group_info表格中的groupnam字段的uin要和rm_user_router表格中的loginname字段的uin要一致

    1.先备份2张表

    2.更新同步数据

    update rm_user_router inner join rm_group_info on rm_user_router.loginname=rm_group_info.groupname set rm_group_info.uin=rm_user_router.uin;
    

      

  • 相关阅读:
    js作用域链
    函数声明提升
    18年年终总结之谈谈焦虑这件事
    混合开发中ios兼容问题
    vue 缓存的keepalive页面刷新数据
    vue里监听安卓的物理返回键
    vue根据数组对象中某个唯一标识去重
    Sublime Text3 插件
    全面理解Javascript闭包和闭包的几种写法及用途
    javascript深入理解js闭包
  • 原文地址:https://www.cnblogs.com/steven9898/p/8960942.html
Copyright © 2011-2022 走看看