-3
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
4

1 回答 1

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
于 2012-07-27T17:41:32.090 回答