更新时间:2022-06-05 22:33:44
你想要 UPDATE FROM
:
UPDATE N1
SET N1.is_last_child = 1
FROM Node N1
LEFT OUTER JOIN Node N2
ON N1.ID = N2.Parent_ID
WHERE N2.ID IS NULL
左外连接在概念上与使用 NOT IN
相同,只是它更易于阅读并且您不需要一堆嵌套查询.
The left outer join is conceptually the same as using NOT IN
only it's easier to read and you don't need a bunch of nested queries.