以下是聲明。子查詢自己返回正確的值,但在更新語句中它表示它返回多個值。子查詢本身不起作用,不在更新聲明中
update MasterList
set SSI_Rep = (select [SS Rep] from RepAssign join
MasterList on MasterList.ST = RepAssign.State
and MasterList.RSM = RepAssign.RSM)
以下是聲明。子查詢自己返回正確的值,但在更新語句中它表示它返回多個值。子查詢本身不起作用,不在更新聲明中
update MasterList
set SSI_Rep = (select [SS Rep] from RepAssign join
MasterList on MasterList.ST = RepAssign.State
and MasterList.RSM = RepAssign.RSM)
嘗試以下操作:
UPDATE
MasterList
SET
SSI_Rep = RepAssign.[SS Rep]
from
MasterList
join
RepAssign
on
MasterList.ST = RepAssign.State
and MasterList.RSM = RepAssign.RSM
你是男人(或女人)! – RageQwit 2012-03-08 01:40:37
書面,查詢試圖與SSI_Rep相同的值更新Masterlist所有行。因此,錯誤消息正確地指出您嘗試使用許多值更新行值。我敢打賭,這不是你想做的事情,你想做一個UPDATE FROM查詢:
UPDATE MasterList
SET SSI_Rep = RepAssign.[SS Rep]
FROM MasterList
JOIN RepAssign
ON MasterList.ST = RepAssign.State
AND MasterList.RSM = RepAssign.RSM
你使用的是什麼rdbms? – diaho 2012-03-08 01:32:06
當你說子查詢「返回正確的值」時,你的意思是「返回正確的值」(單數)。如果子查詢返回多行,那麼您的語句將不起作用。 – Glenn 2012-03-08 01:37:36