I am trying to write a query with a recursive self join. My tables are something as below:
Table1
EMP_ID Name
1 Manger1
2 Manger2
3 Manger3
4 Employ1
5 Employ2
Table2
Par_EMP_ID EMP_ID
1 2
2 3
3 4
3 5
Here in above tables the Manager1, Manager2, ..., Employe2 are employees in a company where Manager1 is Head of Dept. Manager2 is reporting to Manager1, Manager3 is reporting to Manager2, this relation ship is maintained in table2 where Par_EMP_ID is EMP_ID of reportii and column EMP_ID is id of reporter. Now I want result as below:
Manager1 Manager2 Manager3 Employe1
Manager1 Manager2 Manager3 Employe2