I have this table and I am confuse how can I generate sql statement on this on how can I get ALL the u_id,that under p_id as there parent id.
here is the output I want if want only 5 as the p_id.
users usernames p_id
7 miller 5
8 jamie 5
9 honey 7
10 jack 7
gather_table
p_id u_id
null 1
1 5
1 6
5 7
5 8
7 9
7 10
user table
user_id user_name
1 millan
2 john
3 max
4 chris
5 jane
6 lester
7 miller
8 jamie
9 Honey
10 Jack
Thank you in advance.
EDIT:
I tried >=6 but it returns 9 and 10,but 6 is never been p_id in my gather table so it has no u_id's on my gather table.
I want to get all the u_id of my p_id which is belong to it(p_id). in my example 5 is p_id of 7 8 9 10, eventhough the p_id of 9 and 10 is 7 but the p_id of 7 is 5,so they are still under 5