Possible Duplicate:
Mysql recursion?
I am trying to get the complete parent information from a child id in a single query. Is it possible?
example :
id | ts_name | parent_id
1 | admin | 0
2 | user | 0
3 | card | 0
4 | pin | 0
5 | venkat | 0
7 | admin_sub | 1
18 | admin_sub2 | 7
19 | admin_sub2.1 | 18
23 | admin_sub1 | 7
27 | admin_sub3 | 7
30 | ghgfh | 26
37 | vbnvbn | 7
38 | add_sub_1 | 1
41 | admin_sub2.2.1 | 19
42 | admin_sub2.1.1.1 | 20
43 | admin_sub2.1.1.1 | 19
So what I am trying to get is
when I give child id = 19 it should return: 18,7,1
How to do that?