天天看點

oracle 多表關聯更新,需要更新的字段在另一個表裡

兩表(多表)關聯update -- 被修改值由另一個表運算而來

update customers a -- 使用别名

set city_name=(select b.city_name from tmp_cust_city b where b.customer_id=a.customer_id)

where exists (select 1 from tmp_cust_city b where b.customer_id=a.customer_id)

-- update 超過2個值

update customers a -- 使用别名

set (city_name,customer_type)=(select b.city_name,b.customer_type from tmp_cust_city b where b.customer_id=a.customer_id)

where exists (select 1from tmp_cust_city b where b.customer_id=a.customer_id)