Hallo,
I've a table that looks something like this:
id, parentID, name
ParentId links to id.
Now I would like to get all "child-nodes" for a given parentId.
The recursion goes 4 levels deep.
What I've so far is:
Ok that works but the result ist quiet ugly
What I get is something like
Now I could use VBA to take a look at each column and store all unique numbers... but is there a more simpler way?
Thanks
I've a table that looks something like this:
id, parentID, name
ParentId links to id.
Now I would like to get all "child-nodes" for a given parentId.
The recursion goes 4 levels deep.
What I've so far is:
Code:
SELECT t1.id, t2.id, t3.id, t4.id
FROM tblPersons AS t4
INNER JOIN (tblPersons AS t3
INNER JOIN (tblPersons AS t1
INNER JOIN tblPersons AS t2 ON t1.id = t2.parentId) ON t3.parentId = t2.id) ON t4.parentId = t3.id
WHERE (t1.id=1234);
Ok that works but the result ist quiet ugly
What I get is something like
Code:
id1...id2...id3...id4
1 20 50 51
1 20 50 52
1 20 60 53
1 20 60 54
Now I could use VBA to take a look at each column and store all unique numbers... but is there a more simpler way?
Thanks