ID EMP_ID EMP_NAE MANAGER_ID
1 1 KARAN 2
2 2 K VEDI 3
3 3 SOMYA 2
4 4 KAVITA 3
5 5 AMAN 2
答案 0 :(得分:1)
有关员工及其经理的列表,请使用:
select emp_nae as [Employee name], man.emp_nae as [Manager name]
from tablename as emp
left join tablename as man on man.emp_id = emp.manager_id
有关经理和他们的员工的列表使用此:
select emp_nae as [Employee name], man.emp_nae as [Manager name]
from tablename as man
join tablename as emp on man.emp_id = emp.manager_id