The scenario is this
key | value | sponsor_id
===================================
1 | mykel | 0
2 | sydney | 1
3 | darren | 2
4 | luis | 3
What I want to achieve is something like this
SELECT * FROM tbl WHERE sponsor_id = 0;
So basically, "mykel" field is the on that will be selected. But, I also want to select all the child element of sponsor_id 0;
As stated in the table
- 1 is connected to 0
- 2 is connected to 1
- 3 is connected to 2
In conclusion, I want to select rows starting from the parent index which is 0 and also all the child rows connected to it wether directly or indirectly.
Is it achievable using one straight query?