递归上下级部门,获取相关的部门单位
- 部门表:
- sql语句:
with Temp1 as ( select GroupID,G_ParentID from sys_Group where GroupID={当前部门GroupID} union all select sys_Group.GroupID,sys_Group.G_ParentID from Temp1 inner join sys_Group on Temp1.G_ParentID=sys_Group.GroupID ), Temp2 as ( select GroupID,G_ParentID from sys_Group where GroupID={当前部门GroupID} union all select sys_Group.GroupID,sys_Group.G_ParentID from Temp2 inner join sys_Group on Temp2.GroupID=sys_Group.G_ParentID ) select GroupID from Temp1 union select GroupID from Temp2
时间: 2024-10-05 11:37:57