views:

19

answers:

1
------------------
ID    Name     Mgr
------------------
1    Ajay      4
2    Vijay     5
3    Nayeem    1
4    Rakesh    3
5    Varun     4
6    Bhupesh   1
-----------------

I want the result as

-----------------
Name     Mgr
-----------------
Ajay     Rakesh
Vijay    Varun
Nayeem   Ajay
Rakesh   Nayeem
Varun    Rakesh
Bhupesh  Ajay
A: 
Select sub.name , sup.name 
from yourtab sub
join yourtab sup
on sup.id = sub.mgr

;

James Anderson
Your query is almost correct after doing changing last line.Select sub.name , sup.name from yourtab sub join yourtab sup on sup.mgr = sub.id
NayeemKhan