1 with companyNodes(ParentNodeID,NodeID,NodeTypeID,level) as 2 ( 3 select n.ParentNodeID,n.NodeID,n.NodeTypeID,0 level 4 from tblclient_companyowner as o inner join tblSys_Node as n on o.NodeID=n.NodeID 5 where o.CompanyID=238 6 union all 7 select n.ParentNodeID,n.NodeID,n.NodeTypeID,companyNodes.level+1 8 from companyNodes inner join tblSys_Node n on companyNodes.NodeID=n.ParentNodeID 9 ) 10 11 select * from companyNodes where NodeTypeID=4
时间: 2024-11-11 16:10:42