我收到了错误:"表名称' temp'指定不止一次"当试图在两个表上执行连接时。 我所看到的每个例子都是我的,所以出了什么问题?
UPDATE info.temp
SET RobberID = info.Robber.RobberID
FROM info.temp
INNER JOIN info.Robber
ON info.temp.NickName = info.Robber.NickName;
答案 0 :(得分:2)
尝试其中一个
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)
答案 1 :(得分:0)
您正在以错误的方式通过值格式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);