The associated fields of the two tables in Mysql are inconsistent

I encountered a problem at work, and the mass mailing system failed. Later, I found the reason after investigation.

It turns out that the associated fields of the two tables in mysql are inconsistent.

Table 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 | |
+------------+-------------+------+-----+---------+-------+

Form 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 | |
+----------------+---------------+------+-----+---------+-------+

The UIN fields of the two tables are actually inconsistent. What needs to be solved now is that the uin of the groupnam field in the rm_group_info table must be consistent with the uin of the loginname field in the rm_user_router table.

1. Backup 2 tables first

2.

1 update rm_router_user inner join rm_group_info on rm_router_user.loginname=rm_group_info.groupname set rm_group_info.uin=rm_user_router.uin;
View Code

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324972920&siteId=291194637