I have this 4 level user table as below
user_id parent_id
1 NULL
2 1
3 2
4 2
5 3
6 1
I would like to select all user under a certain parent id, for example, user_id = 1 and in this case shall return result like below:
user_id parent_id
2 1 // return because parent_id = 1
6 1 // return because parent_id = 1
3 2 // return because parent_id of 2 is 1
4 2 // return because parent_id of 2 is 1
5 3 // return because parent_id of 3 is 2
By providing an id, what would be the query?
Thanks in advance!