关于两表关联的update,可以把SQL写成了在SQL Server下面的特有形式,但是这种语法在Oracle下面是行不通的
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
)
-
资料引用:http://www.knowsky.com/347147.html
本文提供了一个在SQLServer中使用关联表进行更新操作的例子,该例子展示了如何通过子查询来更新目标表中的字段,并指出了这种方法在Oracle环境下将不可用。
1万+





