Self join in the HR schema
I'm a beginner going though a tutorial on joins using the HR schema:
an example of a self join was given as:
SELECT e.last_name AS Employee, m.last_name AS Manager
FROM employees e INNER JOIN employees m
ON (e.manager_id = m.employee_id);
this executes correctly, giving a column of Employee's name and their manager's name . However, I'm having trouble wrapping my head around the ON clause in this statement.
For example if I change the ON clause so that the statement is:
SELECT e.last_name AS Employee, m.last_name AS Manager
FROM employees e INNER JOIN employees m
ON (m.manager_id = e.employee_id);
I no longer get the correct answer but I'm not sure why?