56,677
社区成员
发帖
与我相关
我的任务
分享
update a inner join b on a.atitle=b.btitle
set a.pic=b.bpic
mysql> select * from a;
+------+--------+------+
| id | atitle | pic |
+------+--------+------+
| 1 | aa | bb |
| 2 | cc | dd |
| 3 | dd | rr |
+------+--------+------+
3 rows in set (0.00 sec)
mysql> select * from b;
+------+--------+------+
| id | btitle | bpic |
+------+--------+------+
| 1 | cc | ee |
| 2 | aa | tt |
+------+--------+------+
2 rows in set (0.00 sec)
mysql> update a ,b set a.pic=b.bpic where a.atitle=b.btitle ;
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> select * from a;
+------+--------+------+
| id | atitle | pic |
+------+--------+------+
| 1 | aa | tt |
| 2 | cc | ee |
| 3 | dd | rr |
+------+--------+------+
3 rows in set (0.00 sec)