SQL递归查询

来源:互联网 发布:光纤网络和普通网络 编辑:程序博客网 时间:2024/05/21 11:00
with dates as
(
    select Id,Name from BaseData where Id = 5  --查询节点
    union all
    select a.Id,a.Name
    from BaseData a join dates b on a.ParentId = b.id
    where a.id is not null
)
 
select * from dates
0 0
原创粉丝点击