SQL update 多表关联更新
实现多表更新,尤其是A表和A的子表B表数据更新,下面是例子
有A、B张表,其记录如下:
A表
c1?????? c2
--------------
1?????? a1
2?????? a2
3?????? a3
8?????? a8
B表
c1?????? c3
--------------
1??????? b1
2??????? b1
3??????? b3
10????? b10
A.c1与B.c1相等,用一条sql语句,实现A.c2的值更新为B.c3
---------------------------------------------------------------------------------------
语句一
UPDATE A SET A.c2 =B.c3
from A ,B
where A.c1=B.c1
语句二
UPDATE??? A
SET A.c2 =B.c3
from A inner join B on A.c1=B.c1