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 1
from tmp_cust_city b
where b.customer_id=a.customer_id
)
本文介绍了一种使用SQL进行数据更新的方法,特别是如何从另一个临时表中选择数据来更新目标表的多个字段。通过这种方式,可以有效地同步两个表之间的数据。
174

被折叠的 条评论
为什么被折叠?



