Now I found a way for the view to work as I expect :
---
create view dad_area_tree as
select a2.area_id as seed, a1.*
from dad_areas as a1, dad_areas as a2
where
a1.area_id = a2.area_id
or
(
a1.level_1 = a2.level_1
and a1.level_2 = 0
)
or
(
a1.level_1 = a2.level_1
and a1.level_2 = a2.level_2
and a1.level_3 = 0
)
or
(
a1.level_1 = a2.level_1
and a1.level_2 = a2.level_2
and a1.level_3 = a2.level_3
and a1.level_4 = 0
)
or
(
a1.level_1 = a2.level_1
and a1.level_2 = a2.level_2
and a1.level_3 = a2.level_3
and a1.level_4 = a2.level_4
and a1.level_5 = 0
)
or
(
a1.level_1 = a2.level_1
and a1.level_2 = a2.level_2
and a1.level_3 = a2.level_3
and a1.level_4 = a2.level_4
and a1.level_5 = a2.level_5
and a1.level_6 = 0
);
---
Now I can ask like this to get whole tree:
select * from dad_area_tree where seed = 13; -- 13 means any validy area_id
PS.: To : Don Baccus answer
What do you mean with "DAG" ?
Where I can have a look at the data model you mentioned ?