缺少选择关键字

时间:2015-12-09 00:07:27

标签: oracle oracle10g

 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

它给出了Missing Select Keyword错误,任何人都知道如何用oracle10g中的CTE解决更新?

1 个答案:

答案 0 :(得分:1)

请尝试使用合并。它与 with 类似。

 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;

合并会在 Table2 中的 Table1 中发现 a ,并将替换行程强>模式即可。

示例在这里: SQL Fiddle demo