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

一个更新表的问题,求助各位大虾,急,在线等
有两个表tableA,tableB
tableA字段   key,B,C,   D
tableB字段   key,   B,   C,   D
其中key都是各个表的主键
我现在想把tableB中的数据更新到tableA中,但是老报错,可能我的语句写的有问题,事情很急,请各位大虾帮忙给一条正确语句,小弟在此谢谢了

我的语句是:
update   tableA   set   tableA.B=tableB.B,tableA.C=tableB.C,tableA.D=tableB.D   where   tableA.key=tableB.key

PS:由于tableA中还有一些其他字段不用修改,所以只能用update的方法,不能使用insert方法



------解决方案--------------------
update a
set
a.B=b.B,a.C=b.C,a.D=b.D
from
tableA a,tableB b
where
a.key=b.key
------解决方案--------------------
update tableA set tableA.B=tableB.B,tableA.C=tableB.C,tableA.D=tableB.D where tableA.[key]=tableB.[key]
------解决方案--------------------
掉了from

update tableA set tableA.B=tableB.B,tableA.C=tableB.C,tableA.D=tableB.D From tableA, tableB where tableA.[key]=tableB.[key]
------解决方案--------------------
update a set a.B=b.B,a.C=b.C,a.D=b.D from tableA a,tableB b where a.[key]=b.[key]