更新不起作用

时间:2014-12-23 12:07:03

标签: sql

UPDATE dwh.product_in_offer AS t 
SET (t.PRODUCT_BUCKET_TYPE_CODE,t.PRODUCT_BUCKET_TYPE_DESC,t.LAST_EDIT_TYPE,t.CREATE_ID,t.UPDATE_ID) = 
    (SELECT s.PRODUCT_BUCKET_TYPE_CODE, s.PRODUCT_BUCKET_TYPE_DESC, s.LAST_EDIT_TYPE, s.CREATE_ID, s.UPDATE_ID
     FROM dwh.product_in_offer_vw AS s
     WHERE create_id = 0
        AND t.PRODUCT_KEY = s.PRODUCT_KEY 
        AND t.OFFER_KEY=s.OFFER_KEY) 
INNER JOIN dwh.product_in_offer_vw p on t.PRODUCT_KEY=p.PRODUCT_KEY and t.OFFER_KEY=p.OFFER_KEY
WHERE  create_id = 0;
  

错误:INNER附近的语法错误,偏移386和#34; .. ND t.OFFER_KEY = s.OFFER_KEY) - > INNER< - "

任何想法??

1 个答案:

答案 0 :(得分:2)

INNER JOIN子句必须先于SET子句。

UPDATE dwh.product_in_offer AS t 
INNER JOIN dwh.product_in_offer_vw p on t.PRODUCT_KEY=p.PRODUCT_KEY and t.OFFER_KEY=p.OFFER_KEY
SET (t.PRODUCT_BUCKET_TYPE_CODE,t.PRODUCT_BUCKET_TYPE_DESC,t.LAST_EDIT_TYPE,t.CREATE_ID,t.UPDATE_ID) = 
    (SELECT s.PRODUCT_BUCKET_TYPE_CODE, s.PRODUCT_BUCKET_TYPE_DESC, s.LAST_EDIT_TYPE, s.CREATE_ID, s.UPDATE_ID
     FROM dwh.product_in_offer_vw AS s
     WHERE create_id = 0
        AND t.PRODUCT_KEY = s.PRODUCT_KEY 
        AND t.OFFER_KEY=s.OFFER_KEY) 
WHERE  create_id = 0;