I would like to retrieve all children from a given parent (and optionally their level depth). Also, if possible, I would like to get it in a single query or store procedure.
Something like this solution by Mark Byers, only in reverse direction.
My table structure is like this:
id parent
1 0
2 1
3 0
4 1
5 2
6 5
7 2
8 4
so i f want the children for 1 I'll get:
+2
++5
+++6
++7
+4
++8
if want the children for 2 I'll get:
++5
+++6
++7
and if want the children for 4 I'll get:
+8
Thanks in advance!
EDIT 1: nested set model is no good to me