ID---parentID
1------NULL <<<<Parent 1
2--------1<<<<<<Child 1 of Parent 1
3--------1<<<<<<Child 2 of Parent 1
4-----NULL<<<<Parent 2
5--------4 <<<<<<Child 1 of Parent 2
6------NULL<<<<Parent 3
7--------6<<<<<<Child 1 of Parent 3
10-----NULL<<<<Parent 4
11-----NULL<<<<Parent 5
12-------2<<<<<<<Grandchild of 1, Child 1 of Child 1 of Parent 1
This is the table layout for a database fed jscript menu that works fine for the first two levels, but will not display the third or grandchild level.
I understand the first Select statement below dictates the inner recursion of the second select statement but cannot figure a way around it. Here are the SELECT statements:
(Est. record set etc)
sSql="SELECT ID,Title,parentID FROM quick WHERE parentID IS NUll"
While Not rs.EOF
This selects the parents, then before I move to the next record the second SELECT statement and recordset is called and is moved to the next record.
(Est. record set etc)
Sql="SELECT parentID, Title, ID FROM quick WHERE parentID = " & ID
While Not Rrs.EOF
This SELECT statement chooses the children for each parent, then I move to the next record:
Rrs.MoveNext
Wend
rs.MoveNext
Wend
I can see why I cannot get the grandchild (ID=12) with this recursion but I am lost as to how to add the third level. Any help would be appreciated.
1------NULL <<<<Parent 1
2--------1<<<<<<Child 1 of Parent 1
3--------1<<<<<<Child 2 of Parent 1
4-----NULL<<<<Parent 2
5--------4 <<<<<<Child 1 of Parent 2
6------NULL<<<<Parent 3
7--------6<<<<<<Child 1 of Parent 3
10-----NULL<<<<Parent 4
11-----NULL<<<<Parent 5
12-------2<<<<<<<Grandchild of 1, Child 1 of Child 1 of Parent 1
This is the table layout for a database fed jscript menu that works fine for the first two levels, but will not display the third or grandchild level.
I understand the first Select statement below dictates the inner recursion of the second select statement but cannot figure a way around it. Here are the SELECT statements:
(Est. record set etc)
sSql="SELECT ID,Title,parentID FROM quick WHERE parentID IS NUll"
While Not rs.EOF
This selects the parents, then before I move to the next record the second SELECT statement and recordset is called and is moved to the next record.
(Est. record set etc)
Sql="SELECT parentID, Title, ID FROM quick WHERE parentID = " & ID
While Not Rrs.EOF
This SELECT statement chooses the children for each parent, then I move to the next record:
Rrs.MoveNext
Wend
rs.MoveNext
Wend
I can see why I cannot get the grandchild (ID=12) with this recursion but I am lost as to how to add the third level. Any help would be appreciated.