I am trying to create a SQL query to select records from a table and order them the way I want the ordered. I am sure it is possible but I just can't figure it out right now.
Imagine the following table:
nMsgId nParentId
1 1
8 1
10 1
11 10
12 8
13 12
Now i want to run a select statement:
select nMsgId,nParentId from myTable order by ?????
And I would like the following result
nMsgId nParentId
1 1
8 1
12 8
13 12
10 1
11 10
Is this possible to do?
It will be used for a messagethreading system, kinda like UT messages are organized (don't worry I am not thinking about competing with UT <s>).
Should I stop thinking about running a select statement and run a recursive look type thing instead?
Thanks,
Einar
Semper ubi sub ubi.