SQLSERVER 树级递归查询
-- with一个临时表(括号中是你要查询的列名)
with temp(subject_id,parent_id,Name,curLevel)as
(--1:初始查询(这里的PID=-1 在我的数据中是最底层的根节点)
select subject_id,parent_id,Name,1 as level from Subject
where parent_id = 1
union ...
原创
2020-03-19 14:48:39 ·
434 阅读 ·
0 评论