首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > IBM DB2 >

update用法解决办法

2012-02-28 
update用法如何将a表中的b字段赋值给c表的d字段c.da.b,求解详细说明:我要更新很多条 我要将a中的b字段和c

update用法
如何将a表中的b字段赋值给c表的d字段 c.d=a.b,求解

详细说明:
我要更新很多条 我要将a中的b字段和c表中的d字段
table a table c
b x d x
  1 1
  2 2
  3 3
update c set d=(select b from a where ?) where x in()
我要分别把c表中x=1,2,3对应的d的值赋给a表中x=1,2,3对应的b值
单条更新的我已会写,感谢1楼的回复。
请高手指点 关联性如何写?

[解决办法]

SQL code
update c set d = (    select b from a where a.x = c.x)where exists  (    select b from a where a.x = c.x)
[解决办法]
SQL code
update a set a.字段=(                     select b.字段 from b                    where a.key=b.key) where a.key in (select c.key  from c where a.key=c.key)        b与c为同一个表 

热点排行