黑马程序员技术交流社区

标题: 多表关联更新的SQL写法 [打印本页]

作者: 王宗伟    时间: 2012-4-9 10:52
标题: 多表关联更新的SQL写法
本帖最后由 王宗伟 于 2012-4-10 23:05 编辑

rt{:soso_e117:}
作者: 霍世勇    时间: 2012-4-9 10:54
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
                 )

作者: pray    时间: 2014-4-26 07:26
让网络上纷纷冒出该帖的真人版卡通版搞笑版成人版的好帖  




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2