无限级树型结构

求一个无限级树型结构树型结构是存储商品分类的[解决办法]SQL codewith cte as(select id from tb where p

求一个无限级树型结构
树型结构是存储商品分类的

[解决办法]

SQL code
with cte as(   select id from tb where pid=@id   union all   select a.id from tb a join cte b on a.id=b.pid)select * from cte