直接看图
对应的 sql语句
WITH n AS
(
SELECT RoleCode, DirID
FROM dbo.RolePages WHERE DirID=6 AND RoleCode=4
UNION ALL
SELECT e.RoleCode, e.DirID
FROM RolePages e JOIN n ON n.DirID=e.parentId
)
DELETE FROM RolePages
where DirID IN (SELECT DirID FROM n)
AND RoleCode =4