Without using stored procedures, is there a way to get all parent nodes as individual rows?
Example data:
id | parent_id | name
---------------------
1 | NULL | Cat1
2 | NULL | Cat2
3 | 1 | Cat3
4 | 3 | Cat4
5 | 4 | Cat5
6 | 2 | Cat6
7 | NULL | Cat7
When getting all parents for row where id = 5
, results would be:
id | parent_id | name
---------------------
1 | NULL | Cat1
3 | 1 | Cat3
4 | 3 | Cat4
I should note: I'm ok with doing multiple joins (thereby creating a fixed limit to the number of parents retrieved).