SQL Server - Select EmployeeName and ManagerName from the table

Asked By Aman Kedia on 06-Sep-16 12:56 PM
Table Employee

EmpId Name Salary ManagerId
1 Aman 1200 2
2 John 2500 3
3 Stev 1800 4
4 Kriti 2000 5
5 Tina 2500 1

print the employeeName along with their Managername

Note : ManagerId is from the same table column EmpId

Please help me.
bhanupratap singh replied to Aman Kedia on 13-Sep-16 03:31 PM
Write like this.


from tblEmployeeTable e
inner join  tbDesignation d
on e.empId=d.empId
where e.empid=@empid
 it will give you employee details with manager name.
For manager name you will have to use tbldesignation
Shriya S replied to Aman Kedia on 06-Jun-17 09:54 AM
select * from tbl_employee(nolock) e
inner join tbl_manager(nocock) m on m. empid=e.empid
where e.managerid=@managerid

For manager u needto use this table " tbl_manager"

Along with employee names manager names will print

I think this will useful for u