猿问

sql 递归查询 急 路过的朋友看看

表结构    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的子集
慕尼黑8549860
浏览 341回答 1
1回答

潇湘沐

应该取【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
随时随地看视频慕课网APP
我要回答