Table 多次指定名称

Table name is specified more than once

我在尝试对两个表执行连接时收到错误:"table name 'temp' specified more than once"。 我看过的每个例子都和我的一样,所以有什么问题吗?

UPDATE info.temp
SET RobberID = info.Robber.RobberID
FROM info.temp
INNER JOIN info.Robber
ON info.temp.NickName = info.Robber.NickName;

尝试其中之一

UPDATE t1
SET RobberID = info.Robber.RobberID
FROM info.temp as t1
INNER JOIN info.Robber as t2
ON t1.NickName = t2.NickName;

UPDATE info.temp
SET RobberID = (select info.Robber.RobberID FROM info.Robber
WHERE info.temp.NickName = info.Robber.NickName)

您正在以错误的方式更新 info.temp 按值形式 info.temp 这样做

UPDATE info.temp
SET RobberID =  (select info.Robber.RobberID
FROM info.temp
INNER JOIN info.Robber
ON info.temp.NickName = info.Robber.NickName);