I have this MySql table (default ordered by id):
id subid value
1 0 value 1
2 0 value 2
3 1 sub of 1
4 1 sub of 1
5 2 sub of 2
6 2 sub of 2
7 5 sub of 5
I need a query that returns the list, ordered by the id AND the subid like this:
1 0 value 1
3 1 sub of 1
4 1 sub of 1
2 0 value 2
5 2 sub of 2
7 5 sub of 5
6 2 sub of 2
So, the subs of an id come directly under that id line (in this example id1 has 2 subs and they appear directly under the line with id1. id7 has subid 5 so appears directly under the line with id5
subs can be infinitely deep
How can I get this result?
Thank you!