A 表中有列a,b,c
B表中有列 d,e,f
当A中的c等于B中的f时
让A.a=B.d
A.b=B.e
表A中的c和表B中的f有相同的数据,如果A.c=B.f,那么更新A.a=B.d,A.b=B.e,这样能够解释清楚吗?
B表中有列 d,e,f
当A中的c等于B中的f时
让A.a=B.d
A.b=B.e
表A中的c和表B中的f有相同的数据,如果A.c=B.f,那么更新A.a=B.d,A.b=B.e,这样能够解释清楚吗?
set A.a=B.d,A.b=B.e
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from a inner join b on A.c=B.c
set A.a=B.d,A.b=B.e' at line 1
(0 ms taken)
(0 ms taken)没有影响
+------+------+------+
| a | b | c |
+------+------+------+
| 1 | 2 | 3 |
| 2 | 3 | 4 |
| 3 | 4 | 5 |
+------+------+------+
3 rows in set (0.00 sec)mysql> select * from b;
+------+------+------+
| d | e | f |
+------+------+------+
| 1 | 3 | 5 |
| 2 | 1 | 3 |
| 6 | 7 | 4 |
+------+------+------+
3 rows in set (0.00 sec)mysql> update A,B set A.a=B.d,A.b=B.e where A.c=B.f;
Query OK, 3 rows affected (0.03 sec)
Rows matched: 3 Changed: 3 Warnings: 0mysql> select * from a;
+------+------+------+
| a | b | c |
+------+------+------+
| 2 | 1 | 3 |
| 6 | 7 | 4 |
| 1 | 3 | 5 |
+------+------+------+
3 rows in set (0.00 sec)mysql> select * from b;
+------+------+------+
| d | e | f |
+------+------+------+
| 1 | 3 | 5 |
| 2 | 1 | 3 |
| 6 | 7 | 4 |
+------+------+------+
3 rows in set (0.00 sec)