2015-12-09 85 views
0
With A as (Select Trip, a from Table1), 
     B as (Select pattern, a from Table2), 
     C as (Select Trip, Pattern from Table1 inner join Table2 on Table1.a=Table2.a), 

Update A 
Set A.Pattern = C.Pattern 
From C 
WHERE C.TRIP = A.TRPIP 

它給錯誤的選擇關鍵字,任何人都知道如何解決與oracle10g中的CTE更新?Missing選擇關鍵字

+0

這不是在Oracle中有效的語法,你能解釋一下什麼是你想用樣本數據在這裏實現? –

+0

提示:使用[合併](https://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm) –

回答

1

請儘量使用合併。它將類似於您的

merge into Table1 A 
using (select a, pattern from Table2) B 
on (A.a = B.a) 
when matched then 
    update set A.trip = B.pattern; 

合併會發現一個出現在表1存在於表2 模式更換旅行

例子是在這裏: SQL Fiddle demo