表:
数据:
查询方法:
WITH Tree AS ( SELECT * FROM TableT AS tt WHERE tt.ID=8 UNION ALL SELECT tt.* FROM Tree AS t INNER JOIN TableT AS tt ON t.ID = tt.pCatID ) SELECT * FROM Tree AS t
查出父ID为8的所有节点下的数据
时间: 2024-12-09 10:13:10
WITH Tree AS ( SELECT * FROM TableT AS tt WHERE tt.ID=8 UNION ALL SELECT tt.* FROM Tree AS t INNER JOIN TableT AS tt ON t.ID = tt.pCatID ) SELECT * FROM Tree AS t
查出父ID为8的所有节点下的数据