如果只满足where子句中的语句,我将尝试更新desiredValuefromupdatedTable表,否则不应设置值。下面的陈述是否正确?

 update updatedTable si
 set desiredValue = select desiredValue
                    from otherTable sl
                    where sl.att1 = si.att1 and sl.att2 = si.att2;

最佳答案

尝试如下:

UPDATE updatedTable
set updatedTable.desiredValue = otherTable.desiredValue
FROM otherTable
WHERE updatedTable.att1 = otherTable.att1 and updatedTable.att2 = otherTable.att2

10-06 00:23