Join a table to itself using aliases.
Section: joins
Self join a table
sql
sql
SELECT e.id, e.full_name, m.full_name AS manager_name
FROM employees e
LEFT JOIN employees m ON m.id = e.manager_id;Explanation
Self joins are common in hierarchical data such as org charts.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing joins
Left join to keep unmatched parent rows
Return all rows from the left table and matching rows from the right table.