如何在 self_id 列填充下一条记录时自动触发的触发器中使用以下查询????
UPDATE tree_str
SET L1_Left = ml.self_id,
L1_Centre = mc.self_id,
L1_Right = mr.self_id
FROM tree_str t LEFT JOIN
member ml ON t.self_id = ml.parent_id
AND ml.position = 'LEFT' LEFT JOIN
member mc ON t.self_id = mc.parent_id
AND mc.position = 'CENTER' LEFT JOIN
member mr ON t.self_id = mr.parent_id
AND mr.position = 'RIGHT'
我使用下面的触发器,但它不工作.......
CREATE TRIGGER autoupdate ON [dbo].[tree_str]
FOR UPDATE
AS BEGIN
UPDATE tree_str
SET L1_Left = ml.self_id,
L1_Centre = mc.self_id,
L1_Right = mr.self_id
FROM tree_str t LEFT JOIN
member ml ON t.self_id = ml.parent_id
AND ml.position = 'LEFT' LEFT JOIN
member mc ON t.self_id = mc.parent_id
AND mc.position = 'CENTER' LEFT JOIN
member mr ON t.self_id = mr.parent_id
AND mr.position = 'RIGHT'
END