我有一个脚本:
UPDATE a
SET fieldX =
(SELECT F_Aggregate(x.fieldy)
FROM table_B
INNER JOIN ....
INNER JOIN ....
INNER JOIN ....
....
INNER JOIN table_C on .....
WHERE table_C.fieldY = table_A.fieldY)
FROM table_A a;
但是现在我只想在select给出不同的值时才更新fieldX。
喜欢:
UPDATE a
SET fieldX =
(SELECT dbo.F_Aggregate(x.fieldy) as result
FROM table_B
INNER JOIN ....
INNER JOIN ....
INNER JOIN ....
....
INNER JOIN table_C on .....
WHERE table_C.fieldY = table_A.fieldY)
FROM table_A a
WHERE fieldX <> result;
我找到了这样的问题/答案,但是他们都有一个select语句而没有引用更新的表。 有人知道解决方案吗?
答案 0 :(得分:1)
将计算移到其他 $('#example thead').append(tr><th></th></tr>);
中 - 它可以是CTE,表变量或临时表等。然后用它加入更新的表:
Data Source