WITH RECURSIVE r AS (
SELECT * FROM [表] WHERE id = xxx
union ALL
SELECT [表].* FROM [表], r WHERE [表].id = r.parent_id
)
SELECT * FROM r ORDER BY id;
递归向上查询数据
原文地址:https://www.cnblogs.com/snail90/p/9972447.html
时间: 2024-10-13 10:40:30
WITH RECURSIVE r AS (
SELECT * FROM [表] WHERE id = xxx
union ALL
SELECT [表].* FROM [表], r WHERE [表].id = r.parent_id
)
SELECT * FROM r ORDER BY id;
递归向上查询数据
原文地址:https://www.cnblogs.com/snail90/p/9972447.html