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

SQL中如何把A表指定的字段数据更新到B表指定的字段
比如说有A,B两表。B表有5条数据,而A表的数据记录是灵活的。
互相可以关联的是a表的bnum字段与B表的bnum字段对应。
我现在想把B表中的qiantity字段更新到A表对应的记录的newqiantity字段。

这个SQL语句该如何实现??
急!!!!!

------解决方案--------------------
update A
set newqiantity=B.qiantity
from A,B
where A.bnum=B.bnum
------解决方案--------------------
update a set newqiantity=(select qiantity from b where a.bnum=b.bnum)