作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何在从自身更新同一个表时为表添加别名?
我的查询:
update accounts set adusername = x.adusername
from Accounts x
where x.AccountName = accounts.rev and x.ok>10 and accounts.ok in (0,1,2,3)
and x.ADUserName is not null and accounts.ADUserName is null
错误
Msg 4104, Level 16, State 1, Line 9
The multi-part identifier "accounts.rev" could not be bound.
Msg 4104, Level 16, State 1, Line 9
The multi-part identifier "accounts.ok" could not be bound.
Msg 4104, Level 16, State 1, Line 9
The multi-part identifier "accounts.ok" could not be bound.
Msg 4104, Level 16, State 1, Line 9
The multi-part identifier "accounts.ok" could not be bound.
Msg 4104, Level 16, State 1, Line 9
The multi-part identifier "accounts.ok" could not be bound.
Msg 4104, Level 16, State 1, Line 9
The multi-part identifier "accounts.ADUserName" could not be bound.
最佳答案
这个怎么样:
UPDATE a
SET a.adusername = x.adusername
FROM Accounts x
INNER JOIN Accounts a ON x.AccountName = a.rev
WHERE x.ok>10
AND a.ok in (0,1,2,3)
AND x.ADUserName is not null
AND a.ADUserName is null
关于sql-server - 如何在从自身更新同一个表时为表添加别名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36912594/
我是一名优秀的程序员,十分优秀!