I have got a database created by someone for a development. In that database I have a table like this. This is a modal of that, If parentID is 0 those are super categories.
catID cateName parentID
1 A 0
2 B 0
3 AA 1
4 BB 2
5 AAA 3
6 BBB 4
When navigating through this I can get A-> AA-> AAA
The immediate upper level of 'AAA' is 'AA' and the immediate upper level of 'AA' is 'A'. So at a glance the super category of 'AAA' is 'A'. I want to obtain the super category (Which has parent category as '0') for any sub category. This subcategory flow can be unlimited. Appreciate if someone can help me for constructing a mySQL query to obtain the super category of given sub category.
Thank you.