- 论坛徽章:
- 93
|
回复 1# Linux521
试一下:
- mysql> select * from A;
- +-------+-----------+
- | uacct | user_name |
- +-------+-----------+
- | aaa | axx |
- | bbb | bxx |
- | ccc | cxx |
- +-------+-----------+
- 3 rows in set
- mysql> select * from B;
- +-----+-----------+
- | uid | user_name |
- +-----+-----------+
- | 1 | aaa |
- | 2 | bbb |
- | 3 | ccc |
- +-----+-----------+
- 3 rows in set
- mysql> select * from C
- ;
- +-----+----------+
- | uid | realname |
- +-----+----------+
- | aaa | NULL |
- | bbb | NULL |
- | ccc | NULL |
- +-----+----------+
- 3 rows in set
- mysql> update A, B, C set realname = A.user_name where A.uacct = B.user_name and B.uid = C.uid;
- Query OK, 3 rows affected
- Rows matched: 3 Changed: 3 Warnings: 0
- mysql> select * from C;
- +-----+----------+
- | uid | realname |
- +-----+----------+
- | 1 | axx |
- | 2 | bxx |
- | 3 | cxx |
- +-----+----------+
- 3 rows in set
- mysql>
复制代码
|
|