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
uj5u.com熱心網友回復:
... set (date_id,f2,f3)=(select date_id,b.f2,b.f3 ...)uj5u.com熱心網友回復:
把樓上的陳述句補全了一下。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)
uj5u.com熱心網友回復:
1、oracle中,這種需求要用update,就會用到相關子查詢;
2、如果update的資料集比較大,可能會有性能問題,最好改為merge into語法,具體語法可搜下。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/31407.html
標籤:開發
上一篇:SQL優化
下一篇:sql陳述句的優化,查詢效率低
