Following are some entries from a table:
id r_id a_id p_id1 9 9 0 2 9 105 108 3 9 102 9 4 9 106 105 5 9 108 102
Is it possible to get the following output using SQL query
1 9 9 0 3 9 102 9 5 9 108 102 2 9 105 108 4 9 106 105
The idea is to sort the rows in such a way that a row with p_id = x should come below the row with a_id = x.
I hope question makes sense.
Regards,
Mayank
EDIT:
I'm looking this for PostgreSql
- The root item has a p_id = 0
- There are no missing links