A self-join is a type of JOIN that is used to join a table to itself. It is often used to compare rows within a single table or to create a hierarchical structure. For example, let's say we have a table of employees with a manager_id column that references the employee's manager. We can use a self-join to create a hierarchical structure that shows each employee and their respective manager: SELECT e1.name AS employee, e2.name AS manager
FROM employees e1
JOIN employees e2
ON e1.manager_id = e2.employee_id; A must-know for anyone heading into the technical round, this is one of the most frequently asked SQL JOINs interview questions.