Doug,
I don't think you are going to get a SQL statement to order a tree of nodes like you are expecting. Let's say you have a tree of messages like this:
A
B
D
F
G
E
H
I
C
B and C are replies to A, D and E are replies to B, F and G are replies to D, H is a reply to E, I is a reply to H.
The order you want your result would need to be based on a varying length key that represents a traversal route to the node:
A
AB
ABD
ABDF
ABDG
ABE
ABEH
ABEHI
AC
I think your only solution here is to just have the SQL return you the set of nodes. You'll then have to put each row into the tree based on finding the threadparent node in the tree.
>I'm reposting because I got an error during my first post.
>
>eryone.
>
>I've got a unique problem. I'm working on a message board app for my company's intranet. I'm using ASP with foxpro databases and SQL statements. I have a tree which displays the messages just like UT and other sites. My problem is this, I can populate the tree with messages and replys, but the replys do not fall under the correct parent. Here's my SQL statement, and a sample of what I'm talking about.
>
>SELECT * FROM threads ORDER BY thread,thread_parent,thread_level
>
>Wrong order displays:
>
1rst Message
- Reply1
- Reply2
- Reply3
- Reply to Reply2
>
>Correct order would display:
>
1rst Message
- Reply1
- Reply2
- Reply to Reply2
- Reply3
>
>Fields:
>Thread..............|..Thread_Parent.. | MessageID
>2002049105517 | 2002049105517 | 2002049105517
>2002049105517 | 2002049105517 | 2002049105558
>2002049105517 | 2002049105558 | 2002049105622
>2002049105517 | 2002049105558 | 2002049105703
>2002049105517 | 2002049105622 | 2002049105802