I have a table with the fields:
Parent references the primary key ID in the same table (not foreign key).
+----+--------+------------+
| ID | Parent | Title |
+----+--------+------------+
| 1 | 0 | Wallpapers |
| 2 | 1 | Nature |
| 3 | 2 | Trees |
| 4 | 3 | Leaves |
+----+--------+------------+
I'm trying to select a row and all its parents. For example if I select "Leaves" I want to get "Trees", "Nature", and "Wallpaper" as well since that is the parent path up the hierarchy. Is this possible in one query? At the moment I'm using a loop in ColdFusion to get the next parent each iteration but it's not efficient enough.