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

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)
你在建表的时候派衫粗,建立好这2个表之间的关系..我记得有3中选择...就是另外一个表的更新是塌手否影响到和尘镇它关连的表.,
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
update A set newqiantity =
(select qiantity from B where A.bnum = B.bnum)
update a set a.newqiantity=b.qiantity FROM A a left join B b on a.bnum=b.bnum
← 上一篇: 下一篇: →