2017-02-18 126 views
0

任何人都可以協助讓這一個查詢工作。我試圖更新表中的一列的狀態已經加入到其他表使用內部連接更新查詢時出現的問題

下面是該查詢

update 
(select I.account_id, I.sts, I.name_id, CI.CRM_TYPE, I.comments 
    from PPInters I 
     inner join DW.CUST CT 
     on I.account_id = CT.account_id 
     where 
      I.sts is null 
      AND I.comments IS NOT NULL 
      AND CT.CUSTTYPe = 'INTNL') T 

SET T.STS = 'D' 

WHERE T.account_id IN (2000208927,380166014,190180447,166078041,105029075 ) 

我收到「ORA-01779:不能修改映射到非鍵的列-preserved表」錯誤

我想在這裏做的是集I.STS =‘d’一段700個記錄拉昇使用此查詢

select I.account_id, I.sts, I.name_id, CI.CRM_TYPE, I.comments 
      from PPInters I 
       inner join DW.CUST CT 
       on I.account_id = CT.account_id 
       where 
        I.sts is null 
        AND I.comments IS NOT NULL 
        AND CT.CUSTTYPe = 'INTNL' 

我很感激

+0

什麼是在'CI'表的別名你的'select'子句? – mathguy

回答

1

Assumming是account_id在表PPInters主鍵kolumn,
即它的值唯一地標識該表中的記錄:

UPDATE PPInters 
SET STS = 'D' 
WHERE account_id IN (

      select I.account_id 
       /*, I.sts, I.name_id, CI.CRM_TYPE, I.comments */ 
      from PPInters I 
       inner join DW.CUST CT 
       on I.account_id = CT.account_id 
       where 
        I.sts is null 
        AND I.comments IS NOT NULL 
        AND CT.CUSTTYPe = 'INTNL' 

) 
AND account_id IN (2000208927,380166014,190180447,166078041,105029075 ) 
+0

這工作 - 非常感謝 –