表结构
sql语句
--SELECT * FROM T_VIPPart
with cte as
(
SELECT RecID, VIPId,ParentID,MenuName,Content,LinkURL,CreateTime ,Islink from T_VIPPart
where ParentID=0 AND IsDeleted=0 AND Status=3
union ALL
SELECT s.RecID, s.VIPId,s.ParentID,s.MenuName,s.Content,s.LinkURL,s.CreateTime,s.Islink
from cte s inner join T_VIPPart d
on s.RecID = d.ParentID
)
select * from cte
要求是ParentID=0 是根节点 查询 ParentID=0的子集
1 回答
潇湘沐
TA贡献1816条经验 获得超6个赞
应该取【T_VIPPart】表的值。。。
with cte as( SELECT RecID, VIPId,ParentID,MenuName,Content,LinkURL,CreateTime ,Islink from T_VIPPart where ParentID=0 AND IsDeleted=0 AND Status=3 union ALL SELECT d.RecID, d.VIPId,d.ParentID,d.MenuName,d.Content,d.LinkURL,d.CreateTime,d.Islink from cte s inner join T_VIPPart d on s.RecID = d.ParentID ) select * from cte
- 1 回答
- 0 关注
- 340 浏览
添加回答
举报
0/150
提交
取消