需求:
有如下两张表:
| id | username | usercode |
| 1 | tom | 001 |
| 2 | jerry | 002 |
| 1 | user |
| 2 | tom |
| 3 | jerry |
现在需要将表B中的user字段值根据表A中的username换成usercode.
实现:
UPDATE B,A SET B.user= A.usercode WHERE B.user= A.username; 需求:
有如下两张表:
| id | username | usercode |
| 1 | tom | 001 |
| 2 | jerry | 002 |
| 1 | user |
| 2 | tom |
| 3 | jerry |
现在需要将表B中的user字段值根据表A中的username换成usercode.
实现:
UPDATE B,A SET B.user= A.usercode WHERE B.user= A.username; 
被折叠的 条评论
为什么被折叠?