• 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;
    

      

  • 相关阅读:
    Python之matplotlib库学习
    Linux相关指令和操作
    ubuntu安装vim
    classfication中使用图像金字塔和sliding windows提高准确率
    ubuntu16.04+caffe+python接口配置
    caffe中 softmax 函数的前向传播和反向传播
    cplusplus解析
    ZStack之ZDApp_Init解析
    Z-Stack ZMain学习
    ZigBee协议学习之网络层
  • 原文地址:https://www.cnblogs.com/steven9898/p/8960942.html
Copyright © 2020-2023  润新知