一尘不染

多部分标识符无法绑定sql

sql

我在下面的查询中得到多部分无法绑定错误

update nfltx
set 
b.boxno = a.boxno,
b.message = a.message,
b.nameboxno = a.nameboxno,
b.namemsg = a.namemsg,
b.phoneboxno = a.phoneboxno,
b.phonemsg = a.phonemsg

FROM ofltx a JOIN nfltx b 
ON a.ls_fullnam = b.ls_fullnam

但是如果我从boxno消息中删除b并且所有我都没有收到错误。这背后的原因是什么?谢谢你使用SQL Server 2008


阅读 131

收藏
2021-05-16

共1个答案

一尘不染

FROM子句中指定的表别名不能用作SET column_name中的限定符。这是无效的:

update nfltx
set 
b.boxno = a.boxno,
b.message = a.message,
b.nameboxno = a.nameboxno,
b.namemsg = a.namemsg,
b.phoneboxno = a.phoneboxno,
b.phonemsg = a.phonemsg

FROM ofltx a JOIN nfltx b 
ON a.ls_fullnam = b.ls_fullnam

要使其正常工作,请卸下b。列名的别名。

update nfltx
set 
boxno = a.boxno,
message = a.message,
nameboxno = a.nameboxno,
namemsg = a.namemsg,
phoneboxno = a.phoneboxno,
phonemsg = a.phonemsg

FROM ofltx a JOIN nfltx b 
ON a.ls_fullnam = b.ls_fullnam

拉吉

2021-05-16