[英]SQL Server Subquery Error - The Multi-Part Identifier Could Not Be Bound
[英]Update with subquery get error: “The multi-part identifier could not be bound.” (Sql Server 2008)
我正在尝试使用同一表中另一组记录中的值更新表中的一组记录。 当我运行此查询时,出现错误:
讯息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' ;
如果您要给tphase别名t,那么您也需要在update语句中引用该别名,
UPDATE t
set
t.com = t.com + b.com,
...
此错误告诉您tphase
表中没有名为com
的列。 您将需要删除该引用,或将其更改为正确的列名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.