--递归id往下所有内容
with temp ( URE_ID, URE_PARENT_ID,URE_NAME ,URE_TYPE)
as
(
select URE_ID, URE_PARENT_ID,URE_NAME ,URE_TYPE
from ASM_USER_REGION
where URE_PARENT_ID= 23
union all
select a.URE_ID, a.URE_PARENT_ID,a.URE_NAME ,a.URE_TYPE
from ASM_USER_REGION a
inner join temp on a.URE_PARENT_ID = temp.URE_ID
)
select * from temp

 

mssql 递归

 


--递归id往上所有内容
with temp ( URE_ID, URE_PARENT_ID,URE_NAME ,URE_TYPE)
as
(
select URE_ID, URE_PARENT_ID,URE_NAME ,URE_TYPE
from ASM_USER_REGION
where URE_ID= 41
union all
select a.URE_ID, a.URE_PARENT_ID,a.URE_NAME ,a.URE_TYPE
from ASM_USER_REGION a
inner join temp on a.URE_ID = temp.URE_PARENT_ID
)
select * from temp

mssql 递归

来源:https://www.cnblogs.com/ainidewen/p/6912114.html

相关文章:

  • 2021-09-26
  • 2021-07-08
猜你喜欢
  • 2022-12-23
  • 2022-01-31
  • 2021-06-09
  • 2022-12-23
  • 2021-12-19
  • 2021-09-05
  • 2021-06-22
相关资源
相似解决方案