update sd_sales_high_lh
set
date_id = b.date_id,
f2 =b.f2,
f3 = b.f3
from sd_sales_high_lh a join sd_sales_high_lhm b
on a.year_id= b.year_id
and a.store_code=b.store_code
and a.dept_type = b.dept_type
where a.year_id=cur_year
and a.f2 is null怎么才能实现undate
set
date_id = b.date_id,
f2 =b.f2,
f3 = b.f3
from sd_sales_high_lh a join sd_sales_high_lhm b
on a.year_id= b.year_id
and a.store_code=b.store_code
and a.dept_type = b.dept_type
where a.year_id=cur_year
and a.f2 is null怎么才能实现undate
update sd_sales_high_lh a
set (date_id, f2, f3) =
(select date_id, f2, f3
from sd_sales_high_lhm b
where a.year_id = b.year_id
and a.store_code = b.store_code
and a.dept_type = b.dept_type)
where 1 = 1
and exists (select 1
from sd_sales_high_lhm b
where a.year_id = b.year_id
and a.store_code = b.store_code
and a.dept_type = b.dept_type)
1、oracle中,这种需求要用update,就会用到相关子查询;
2、如果update的数据集比较大,可能会有性能问题,最好改为merge into语法,具体语法可搜下。