今天凌晨因?yàn)橐跀?shù)據(jù)庫里做一些操作,是關(guān)于兩表關(guān)聯(lián)的update,但語句怎么寫都不正確,老是報(bào)錯(cuò),于是心驚肉跳(就怕不能及時(shí)完成操作)去查了一下,NND,原來把SQL寫成了在SQL Server下面的特有形式,這種語法在Oracle下面是行不通的,急忙改回來,及時(shí)完成了任務(wù)。順便也把查到的SQL帖出來,哪天再忘記了,也好在這里找回來:
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個(gè)值
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
)
新聞熱點(diǎn)
疑難解答
圖片精選