首页 > 代码库 > 两表(多表)关联update的写法 .

两表(多表)关联update的写法 .

原文:两表(多表)关联update的写法 .

关于两表关联的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

<script type="text/javascript">// </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">// </script><script type="text/javascript">// </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">// </script>