Recursive JOINs
suggest changeRecursive joins are often used to obtain parent-child data. In SQL, they are implemented with recursive common table expressions. WITH RECURSIVE is required by PostgreSQL and rejected by SQL Server. This example assumes People(Name, Parent):
WITH RECURSIVE MyDescendants AS (
SELECT Name, Parent
FROM People
WHERE Name = 'John Doe'
UNION ALL
SELECT People.Name, People.Parent
FROM People
JOIN MyDescendants ON People.Parent = MyDescendants.Name
)
SELECT * FROM MyDescendants;
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents