2017-02-18 64 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

这工作 - 非常感谢 –