我的代码类似于下面显示的代码并且我一直收到错误 - SELECT的结果超过一行
UPDATE myDatabaseOne.myTableOne t1
SET firstFieldToCopy = (SELECT DISTINCT alternateField
FROM myDatabaseTwo.myTableTwo t2
WHERE t1.firstFieldToCopy = t2.alternateField
AND t2.Field <> t2.Field2);
如何让它循环t1中的每个值?
答案 0 :(得分:0)
It sounds like the sub query returns multiple values for (some of) the record(s) updated. You should change it so it is guaranteed only to return a single value, e.g. add TOP 1 in the select (although that does make it more or less pick a value at random)