有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
注意:
update后面是不能跟多表的,但跟在from子句后面
地址:http://www.cnblogs.com/stublue/archive/2010/08/05/1792977.html