How can I create sql statement on this, to output like this, I tried inner join but I could not get the name of p_id in usertable.
user_id user_name p_name pid
1 millan null
5 jane millan 1
6 lester millan 1
7 miller jane 5
8 jamie jane 5
here is my table. gather_table
p_id u_id
null 1
1 5
1 6
5 7
5 8
user table
user_id user_name
1 millan
2 john
3 max
4 chris
5 jane
6 lester
7 miller
8 jamie
Thank you in advance.