W
Wernfried Schwenkner
Sorry, but I didn't find a group for SQL questions. May be someone can
answer here.
In my app I want to reflect a hirarchy in a tree view. Therefore in the
database I have a table like this:
HirachyId (primary key)
ParentHirarchyId (key to reflect the arent entry)
CategoryId (a foreign key into a category table)
Content may be like the following (0 is root hirarchy)
1 0 10
2 0 11
3 1 16
4 1 8
5 3 27
6 3 28
0
+-- 1
| +-- 3
| | +-- 5
| | +-- 6
| |
| +-- 4
|
+-- 2
Now I want a SQL-select statement which "recursive" gives me all records
for a given node, i.e., when the node is "1" I want to get the records
1 0 10
3 1 16
4 1 8
5 3 27
6 3 28
Can this be done with a SQL-statement?
answer here.
In my app I want to reflect a hirarchy in a tree view. Therefore in the
database I have a table like this:
HirachyId (primary key)
ParentHirarchyId (key to reflect the arent entry)
CategoryId (a foreign key into a category table)
Content may be like the following (0 is root hirarchy)
1 0 10
2 0 11
3 1 16
4 1 8
5 3 27
6 3 28
0
+-- 1
| +-- 3
| | +-- 5
| | +-- 6
| |
| +-- 4
|
+-- 2
Now I want a SQL-select statement which "recursive" gives me all records
for a given node, i.e., when the node is "1" I want to get the records
1 0 10
3 1 16
4 1 8
5 3 27
6 3 28
Can this be done with a SQL-statement?