For example i have table that looks like this:
| ID (This is primary key) | parent (this refers to other rows in this table) |
|--------------------------|--------------------------------------------------|
| 1 | NULL |
| 2 | 3 |
| 3 | 1 |
Is it possible to have ONE mysql query which would return me all hierarchy of parents till it hits NULL?
For example if i would ask for row 2 parents, i want to get row 2, then row 3 and row 1. And if i would ask for row 3 parents, i want to get row 3 and row 1.
(By the way, I want my table to have multiple rows with NULL parents).
Is this possible, if yes how to do it?