SQL中如何把A表的字段数据更新到B表的字段

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

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

首先,你的问题就问的前后矛盾,标题描述是用A表某个字段更新B表的字段,举例子时又说用B表的qiantity更新A表的newqiantity?
假设A表有字段bnum和newqiantity,B表有字段bnum和qiantity,用B表的qiantity值更新对应的A表中的newqiantity值。以Oracle数据库为例:SQL语句如下:
update A set (newqiantity)=(select qiantity from B where A.bnum=B,bnum)
温馨提示:答案为网友推荐,仅供参考
第1个回答  2007-05-24
你在建表的时候,建立好这2个表之间的关系..我记得有3中选择...就是另外一个表的更新是否影响到和它关连的表.,
第2个回答  推荐于2017-09-24
update
    (select A.bnum ,A.newqiantity,B.qiantity from A left join B on A.bnum=B.bnum) AS C
set C.newqiantity = C.qiantity
where C.bnum =XX本回答被提问者采纳
第3个回答  2007-05-24
update A set newqiantity =
(select qiantity from B where A.bnum = B.bnum)
第4个回答  2019-01-28
update a set a.newqiantity=b.qiantity FROM A a left join B b on a.bnum=b.bnum