Sql 递归查询

WITH tab AS(
 SELECT * FROM table1 WHERE Id='9' UNION ALL
 SELECT * FROM tab,table1 WHERE table1.Id=tab.ParentId
)
SELECT * FROM tab;

 

posted @ 2021-07-21 14:36  87de海雷  阅读(38)  评论(0)    收藏  举报