Here is my categories table
category_id | parent_id
____________________________
27 | 25
28 | 27
29 | 25
26 | 28
25 | 0
30 | 0
31 | 26
..........
..........
I want to show the records like this.
category_id | parent_id
____________________________
25 | 0
27 | 25
28 | 27
26 | 28
31 | 26
29 | 25
30 | 0
..........
..........
I have seen lots of post on it but I find nothing for me. Please let me know query for my categories table. Thanks. Here are some links that i have looked already. 1: enter link description here 2: enter link description here