sql查询分类和所有子类

select * from [JianDu].[dbo].[ZuZhiJiGou] where id = 64 --查询节点
union all
SELECT TOP 1000 a.*
FROM [JianDu].[dbo].[ZuZhiJiGou] a join [JianDu].[dbo].[ZuZhiJiGou] b on a.pId = b.id
where a.Pid = 64

posted @ 2017-07-09 16:24  sharncode  阅读(2232)  评论(0编辑  收藏  举报