Skip to content

Instantly share code, notes, and snippets.

@AllenJB
Last active June 30, 2018 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AllenJB/872553b5cb2086b0b8de9b0c50044ce5 to your computer and use it in GitHub Desktop.
Save AllenJB/872553b5cb2086b0b8de9b0c50044ce5 to your computer and use it in GitHub Desktop.
MySQL join same table on different fields
SELECT table1.employee_id_1, table1.employee_id_2, e1.first_name AS e1_first_name, e2.first_name AS e2_first_name
FROM table1
LEFT JOIN employee_tbl AS e1 ON table1.employee_id_1 = e1.employee_id
LEFT JOIN employee_tbl AS e2 ON table2.employee_id_2 = e2.employee_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment