, . , root node, , .
, WHERE, , ID=1 Name=Bld 26. , ( , ), WHERE, .
, , , WHERE ID=1 , . Union'd SELECT , Derived Recursive .
- :
WITH RECURSIVE my_tree AS (
SELECT
ID as Child,
ParentID as Parent,
Name,
Name as Address
FROM <table>
WHERE <table>.ID = 1
UNION
SELECT
table.id as Child,
table.parent_id as Parent,
table.name,
t.address || ', ' || table.name as Address
FROM my_tree as t
INNER JOIN <table> table ON
t.Child = table.Parent_Id
)
SELECT Child, Address from my_tree;
PostgreSQL, , , RDBMS.