当前位置: 数据库>sqlserver
sql多表级联更新update的用法举例
来源: 互联网 发布时间:2014-08-29
本文导语: 两个表级联更新(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.cust...
两个表级联更新(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 多于二个表 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 ) --by 脚本学堂 http://www.