多表联合查询更新

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u014642915/article/details/85620889

两个表a,b 根据a,b两表的客户ID号去更新a表中的客户的城市名称,具体写法如下:

update table_name 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)

猜你喜欢

转载自blog.csdn.net/u014642915/article/details/85620889