使用UPDATE的SQL SERVER中的多部分标识符错误

时间:2015-04-29 10:39:37

标签: sql-server

我遇到了这个错误:

Msg 4104, Level 16, State 1, Line 2
The multi-part identifier "minus.groupby" could not be bound.

每当我尝试使用此代码时:

UPDATE chadothercharges
SET jan = (SELECT Jan from chadothercharges WHERE chadothercharges.groupby = minus.groupby)
FROM CHADothercharges

Chadothercharges和Minus都是TABLE

Chadothercharges table column:

acctcode | acctdesc  |  type  |  orderby  |   groupby | Jan


Minus table column:

groupby | MIN | MAX

1 个答案:

答案 0 :(得分:0)

我认为你应该看看减去表的定义,绝对不会有groupby列。

观看表结构后查询将如下:

UPDATE chadothercharges SET jan = (SELECT Jan 
                                  from chadothercharges INNER JOIN 
                                  Minus ON Minus.groupby = chadothercharges.groupby)