遞迴 JOIN
遞迴連線通常用於獲取父子資料。在 SQL 中,它們使用遞迴公用表表示式實現 ,例如:
WITH RECURSIVE MyDescendants AS (
SELECT Name
FROM People
WHERE Name = 'John Doe'
UNION ALL
SELECT People.Name
FROM People
JOIN MyDescendants ON People.Name = MyDescendants.Parent
)
SELECT * FROM MyDescendants;