日期:2014-05-18  浏览次数:20539 次

今日问题是MSSQL数据更新
我有两个表.
table1
字段1 字段2 字段3
No(唯一) Desc Subsystem
A '不明' 'Audio'
B '1号' 'Vido'
C '2号' null

table2
字段1 字段2 字段3 字段4
No(唯一) Desc Subsystem Model
A
B
C

我现在需要的是将table1中的数据Desc,与Subsystem根据No放入到table2.应该怎么做?


字段1 字段2 字段3 字段4
No(唯一) Desc Subsystem
A '不明' 'Audio'
B '1号' 'Vido'
C '2号' null

------解决方案--------------------
update b
set b.字段3 = a.字段3
from table1 a join table2 b on a.NO=b.NO
------解决方案--------------------
SQL code
update b set b.字段3 = a.字段3
from table1 a, table2 b where a.NO=b.NO

------解决方案--------------------
SQL code

update  b
set b.字段3=a.字段3
from a
where a.NO=b.NO

------解决方案--------------------
晕,要超链接
http://topic.csdn.net/u/20120202/09/a53c96a9-fa51-46be-9b4e-62d345c180a3.html