加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Oracle 用一个表字段更新另一个表字段三种方法

发布时间:2020-12-12 16:12:01 所属栏目:百科 来源:网络整理
导读:1. update (select .....) set column1 = column2; update (select iy.company_name company_name1,cc.company_name_jc company_name2 from income_year_item iy,city_company cc where iy.company_code = cc.code ) set company_name1 = company_name2; 2

1. update (select .....) set column1 = column2;

update (select iy.company_name company_name1,cc.company_name_jc company_name2
from income_year_item iy,city_company cc

where iy.company_code = cc.code
)
set company_name1 = company_name2;

2.只能单行子查询s

updateCITY_PROJECT_SCALE_INFO cset
(c.value) = (
select d.value from CITY_PROJECT_SCALE_INFO @test d where d.project_id = '7d7fd580a06240b2a9137dc2bbe831e9'
and d.project_id = c.project_id and c.company_code = d.company_code
)
where exists (
select 1 fromCITY_PROJECT_SCALE_INFO @test d where d.project_id = '7d7fd580a06240b2a9137dc2bbe831e9'
and d.project_id = c.project_id and c.company_code = d.company_code
)

3.使用merg inot 语句

--更新生产基础字段 merge into city_cfg_data_column_common cf1 using city_cfg_data_column_common2 cf2 on (cf1.resourceid = cf2.resourceid) when matched then update setcf1.template_type = cf2.template_type,cf1.chinese_name = cf2.chinese_name,cf1.column_name = cf2.column_name,cf1.column_type = cf2.column_type,cf1.column_size = cf2.column_size when not matched then insert (cf1.resourceid,cf1.template_type,cf1.chinese_name,cf1.column_name,cf1.column_type,cf1.column_size,cf1.is_can_edit,cf1.is_unique,cf1.is_can_cover,cf1.show_order) values (cf2.resourceid,cf2.template_type,cf2.chinese_name,cf2.column_name,cf2.column_type,cf2.column_size,cf2.is_can_edit,cf2.is_unique,cf2.is_can_cover,cf2.show_order)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读