目录
1.递归查询
--查询树状结构某节点下的所有子节点(
WITH cte_child ( id, ParentID,title,code,value, remark,other,sort,LEVEL ) AS (--起始条件
SELECT
id,
ParentID,
title,
code,
Value,
note,
other,
sort,
0 AS LEVEL
FROM
Dictionary
WHERE
id = 'C72EE719-98EC-485C-816F-3A5EC343627A' --列出父节点查询条件
UNION ALL--递归条件
SELECT
a.id,
a.ParentID,
a.title,
a.code,
a.value,
a.note,
a.other,
a.sort,
b.level + 1
FROM
Dictionary a
INNER JOIN cte_child b ON ( a.ParentID= b.id )
) SELECT
*
FROM
cte_child;