如图,t1,t2表,我想通过t2来更新t1的name,试着写了一个
update t1 a set a.name=(select b.name from t2 b where a.id=b.id)
但这样的话,在t2中不存在的id=3的name就会成空,该怎么写呢?

oracle数据库更新问题,求大神解决
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
4条回答 默认 最新
- 神奇的小帅 2015-12-14 02:57关注
update t1 A a set name= ( select b.name from t2 B where ID = a.ID )
where exists(select t2 1 from B where ID = a.ID )本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报