I have a Hierarchy problem. I have a four level Hierarchy and i need to take the user from the low level to see all the upper levels.I can take the hierarchy from the low level to the upper as you can see:
select * from test1
**username** **NAME** **VALUE**
1 e.gkioka TEAM LEADER x.xrysanthakopo
2 e.gkioka COACH e.gkioka
3 e.xathigianni AGENT e.xathigianni
4 e.xathigianni COACH e.gkioka
5 t.argentis SUPERVISOR t.argentis
6 x.xrysanthakopo SUPERVISOR t.argentis
6 x.xrysanthakopo TEAM LEADER x.xrysanthakopo
here is the username and the roles(AGENT is the low and goes COACH,TEAM_LEADER,SUPERVISOR(upper level))
this is the query for getting the hierarchy for low to the upper
select t1.username as AGENT,t1.value as COACH ,t2.VALUE as TEAM_LEADER,t3.VALUE as SUPERVISOR
from test1 t1,test1 t2, test1 t3
where t1.username='e.xathigianni'
and (t2.USERNAME=t1.VALUE and t1.name='COACH' and t2.name='TEAM LEADER')
and t3.USERNAME=t2.VALUE and t2.name='TEAM LEADER' and t3.name='SUPERVISOR'
that gives me the right hierarchy
AGENT COACH TEAM_LEADER SUPERVISOR
- 1 e.xathigianni e.gkioka x.xrysanthakopo t.argentis
My problem is when i put second level(e.gkioka(COACH)) or third level(x.xrysanthakopo TEAM_LEADER) it doesent give me the right data.