SQL Server 根据一级分类查询所有子级分类

WITH a AS
 (
    SELECT * FROM view_SubjectList WHERE id=1
    UNION ALL 
    SELECT s.* FROM view_SubjectList AS s,a WHERE s.pId=a.ID
)
SELECT * FROM a

 

posted @ 2024-06-27 11:33  microsoft-zhcn  阅读(2)  评论(0编辑  收藏  举报