请教一个简单问题。我要把B表中的ID字段与A表ID字段相同的记录,从B表中选一个字段值插入到A表的一个字段中

就是把B表的一个字段值插入到A表的一个字段中,条件是A.id=B.id

请问如何做?谢谢
---------------------------------------------------------------

update A set A.Booknum=B.Booknum from A,(select Bookid,sum(Booknum) as Booknum from B group by Bookid) B
where A.Bookid=B.Bookid

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus