I am trying to implement a category table. The description of the simplified table looks like this
id -- name -- parent_id
assuming example data for example
id - name - parent_id
1 test1 null
2 test2 null
3 test3 null
4 test4 1
5 test5 4
6 test6 2
7 test7 1
I am trying to come up with a sql query that will return a record in the following order
id - name - parent_id
1 test1 null
4 test4 1
5 test5 4
7 test7 1
2 test2 null
6 test6 2
3 test3 null
Basically, children are returned after their parent.
----------------------- SOLVED BY USING LINQ / recursion in code ------------- ------- -----
Not really a sql solution, but it ultimately works.
source
share