Help me create a table with all the employee Names and Manager Names. SQL OYO interview Questions
Question
Employee_Name Employee_Id Manager_Id
A 1 2
B 2 3
C 3 2
D 4 3
in progress
4
SQL
55 years
18 Answers
1883 views
Grand Master 0
Answers ( 18 )
select e1.Employee_name, e2.Employee_name from Employee e1, Employee e2 where e1.Manager_id=e2.Employee_id;
or
select e1.Employee_name, e2.Employee_name from Employee e1 inner join Employee e2 on e1.Manager_id=e2.Employee_id;
SELECT
e.employee_id
,e.employee_name
,e.manager_id
,m.employee_name AS manager_name
FROM employees e JOIN employees m ON e.manager_id = m.employee_id
SELECT e.EMployee_name ,m.emp_name as Manager_name
FROM Employees e JOIN Employees m
on e.manager_id =m.employee_id;
SELECT Employee_Name, Manager_Name
FROM Employee INNER JOIN Employee_Id = Manager_Id
SELECT Employee_Name, Manager_Name
FROM Employee INNER JOIN Employee_Id = Manager_Id;
SELECT e.Employee_Name, e.Employee_Id, m.Employee_Name as Manager_Name, e.Manager_Id
FROM Employee e INNER JOIN Employee m ON e.Employee_Id = e.Manager_Id
SELECT
e.Employee_name,
m.Employee_name as Manager_name
FROM Employees e
JOIN
Employees m
ON
e.Manager_id = m.Employee_id;
SELECT e.EMployee_name ,m.emp_name as Manager_name
FROM Employees e JOIN Employees m
on e.manager_id =m.employee_id;
select e1.Employee_name, e2.Employee_name from Employee e1 inner join Employee e2 on e1.Manager_id=e2.Employee_id;
SELECT e.Employee_name, m.Employee_name as Manager_name
FROM Employees e JOIN Employees m
on e.manager_id =m.employee_id;
SELECT e1.Employee_Name, e2.Employee_Name As Manager_Name
FROM Employee e1
INNER JOIN Employee e2
WHERE e1.Employee_id = e2.Manager_id
SELECT e1.Employee_Name, e2.Employee_Name AS Manager_name
FROM Employee e1
INNER JOIN Employee e2
WHERE e1.Employee_id=e2.Manager_id
i think the answer will have a left join on the employees E table , am i correct?
SELECT
e.Employee_name,
m.Employee_name as Manager_name
FROM Employees e
LEFT JOIN
Employees m
ON
e.Manager_id = m.Employee_id;
SELECT
E.Employeename,
M.Employeename as Managername
FROM Employees E
LEFT JOIN
Employees M
ON
E.Managerid = M.Employeeid;
SELECT
E.EmployeeName,
M.EmployeeName as ManagerName
FROM Employees E
LEFT JOIN
Employees M
ON
E.ManagerId = M.EmployeeId
i think the answer will have a left join on the employees E table , am i correct?