update table_1 t1 set t1.name=(select t2.name from table_2 where t1.id=t2.id and t1.idcard ='1111')
where exists (select 1 from table_2 where t1.id=t2.id and t1.idcard ='1111')
这是我写的sql 但是执行起来的执行次数是table_1的总条数 求高人解答 很急 现在加班中 求高人帮忙 几十万数据 要是这么执行执行次数就是天文数字了
oracle sql更新字段为另一张表的对应字段
答案:3 悬赏:80
解决时间 2021-02-04 09:28
- 提问者网友:北故人
- 2021-02-04 03:55
最佳答案
- 二级知识专家网友:温柔刺客
- 2021-02-04 05:00
我觉得应该使用merge比较好
merge into table_1 t1
using table_2 t2
on( t1.id=t2.id and t1.idcard ='1111')
when matched then
update name=t2.name;
自己手动敲得没有验证,如不懂用法的话可以百度merge用法看一下就会了
merge into table_1 t1
using table_2 t2
on( t1.id=t2.id and t1.idcard ='1111')
when matched then
update name=t2.name;
自己手动敲得没有验证,如不懂用法的话可以百度merge用法看一下就会了
全部回答
- 1楼网友:都不是誰的誰
- 2021-02-04 06:55
update table_1 t1 set t1.name=(select t2.name from table_2 where t1.id=t2.id)不可以吗?
- 2楼网友:最后战士
- 2021-02-04 05:44
首先你的语句有点问题,应该这样写:
update table_1 t1 set t1.name=(select t2.name from table_2 where t1.id=t2.id)
where exists (select 1 from table_2 where t1.id=t2.id) and t1.idcard ='这很标准啊
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯