Guest_imported
New member
- Jan 1, 1970
- 0
is given a table where i have described a tree it is much more deep but i took this simple example...
so "Parent" shows that the "ID" is a child to the "ID" branch indicated in the "Parent", "Count" shows how many childs do the branch have.
====================================
id = Parent = Name = Count=
====================================
1 | 0 | B3 | 2 |
2 | 5 | B6 | 0 |
3 | 5 | B8 | 0 |
4 | 5 | B1 | 0 |
5 | 0 | B9 | 3 |
6 | 1 | B2 | 0 |
7 | 9 | B7 | 0 |
8 | 1 | B4 | 0 |
9 | 0 | B5 | 1 |
====================================
I need to make a select that will give me these unswer,
it means it shoul be ordered so that first goes the less parent after it the childs o f these parent sorted by id then goes the second smallest parent also with its childs sorted by id..and so on!
So it shoul look this way ...if we took that table!
====================================
id = Parent = Name = count=
====================================
1 | 0 | B3 | 2 |
6 | 1 | B2 | 0 |
8 | 1 | B4 | 0 |
5 | 0 | B9 | 3 |
2 | 5 | B6 | 0 |
3 | 5 | B8 | 0 |
4 | 5 | B1 | 0 |
9 | 0 | B5 | 1 |
7 | 9 | B7 | 0 |
====================================
Thank you very much, waiting for your answers and help as soon as posible!
so "Parent" shows that the "ID" is a child to the "ID" branch indicated in the "Parent", "Count" shows how many childs do the branch have.
====================================
id = Parent = Name = Count=
====================================
1 | 0 | B3 | 2 |
2 | 5 | B6 | 0 |
3 | 5 | B8 | 0 |
4 | 5 | B1 | 0 |
5 | 0 | B9 | 3 |
6 | 1 | B2 | 0 |
7 | 9 | B7 | 0 |
8 | 1 | B4 | 0 |
9 | 0 | B5 | 1 |
====================================
I need to make a select that will give me these unswer,
it means it shoul be ordered so that first goes the less parent after it the childs o f these parent sorted by id then goes the second smallest parent also with its childs sorted by id..and so on!
So it shoul look this way ...if we took that table!
====================================
id = Parent = Name = count=
====================================
1 | 0 | B3 | 2 |
6 | 1 | B2 | 0 |
8 | 1 | B4 | 0 |
5 | 0 | B9 | 3 |
2 | 5 | B6 | 0 |
3 | 5 | B8 | 0 |
4 | 5 | B1 | 0 |
9 | 0 | B5 | 1 |
7 | 9 | B7 | 0 |
====================================
Thank you very much, waiting for your answers and help as soon as posible!