0

我正在尝试使用同一表中另一组记录的值更新表中的一组记录。当我运行此查询时,出现错误:

消息 4104,级别 16,状态 1,行 1
无法绑定多部分标识符“t.com”。

代码:

update tphase
set
   t.com = t.com + b.com,
   t.direct = t.direct + b.direct,
   t.fee = t.fee + b.fee,
   t.fringe = t.fringe + b.fringe,
   t.fte = t.fte + b.fte,
   t.ganda = t.ganda + b.ganda,
   t.hours = t.hours + b.hours,
   t.overhead = t.overhead + b.overhead,
   t.fccmga = t.fccmga + b.fccmga,
   t.fccmoh = t.fccmoh + b.fccmoh,
   t.lbroh = t.lbroh + b.lbroh,
   t.ms = t.ms + b.ms
from
   tphase t 
inner join
   (select *
    from tphase
    where program = 'xenon' and
          class = 'earned' and
          df_date > '2013-05-03'        
   ) as b on t.program = b.program and
             t.cawpid = b.cawpid and
             t.class = b.class and
             t.cecode = b.cecode
where
   t.program = 'xenon' and
   t.class = 'earned' and
   t.df_date = '2013-05-03' ;
4

2 回答 2

3

如果你给 tphase 赋予别名 t,你也需要在更新语句中引用该别名,

UPDATE t
set
    t.com = t.com + b.com, 
...
于 2013-05-13T18:25:46.853 回答
0

此错误告诉您表中没有命名comtphase。您要么需要删除该引用,要么将其更改为正确的列名。

于 2013-05-13T18:20:15.113 回答