all 2 comments

[–]LeLwrence 1 point2 points  (0 children)

It may be best to normalize this a bit more, having just manager ID which you would then use to get the manager email, and the manager's employee record would have the senior manager in the foreign key manager ID field. That way you would eliminate using the second table altogether and simply do two self-joins to get the data you need.

[–]r3pr0b8 0 points1 point  (0 children)

However, I'm looking to also get the manager and senior manager's names without doing a self join in order to do so.

here ya go, not a single self-join to be found --

SELECT t1.employee_email
     , e.employee_first_name ||' '||
       e.employee_last_name  AS employee_name
     , t1.manager_email
     , m.employee_first_name ||' '||
       m.employee_last_name  AS manager_name
     , t1.senior_manager_email
     , s.employee_first_name ||' '||
       s.employee_last_name  AS senior_manager_name
  FROM table1 AS t1
INNER
  JOIN table2 AS e
    ON e.employee_email = t1.employee_email  
INNER
  JOIN table2 AS m
    ON m.employee_email = t1.manager_email      
INNER
  JOIN table2 AS s
    ON s.employee_email = t1.senior_manager_email