Tutorial by Examples

Consider a company where every employee who is a manager, manages 1 or more employees, and every employee has only 1 manager. This results in two tables: EMPLOYEES EMP_IDFIRST_NAMELAST_NAMEMGR_IDE01JohnnyAppleseedM02E02ErinMacklemoreM01E03ColbyPaperworkM03E04RonSonswanM01 MANAGERS MGR_IDFIRST_N...
SELECT e.emp_id , e.first_name , e.last_name FROM employees e INNER JOIN managers m ON m.mgr_id = e.mgr_id WHERE m.mgr_id = 'M01' ; Results in: EMP_IDFIRST_NAMELAST_NAMEE02ErinMacklemoreE04RonSonswan Ultimately, for every manager we query for, we will see 1 or more employees returned.
Consult the above example tables when looking at this example. SELECT m.mgr_id , m.first_name , m.last_name FROM managers m INNER JOIN employees e ON e.mgr_id = m.mgr_id WHERE e.emp_id = 'E03' ; MGR_IDFIRST_NAMELAST_NAMEM03BarrelJones As this is the inverse of the above example, we know that for ...

Page 1 of 1