SELF JOIN
SELF JOIN is a SQL clause in the JOIN Types category. Joins a table with itself. Requires table aliases. The syntax is SELECT a.column, b.column FROM table a JOIN table b ON a.column = b.column;. It returns self-referencing result. A typical example: SELECT e1.name AS employee, e2.name AS manager FROM employees e1 JOIN employees e2 ON e1.manager_id = e2.id; -- Employees with their manager names A close relative is INNER JOIN, which returns only rows where there is a match in BOTH tables. The most common JOIN type. A close relative is LEFT JOIN, which returns ALL rows from the left table and matching rows from the right. Unmatched right rows show NULL. A close relative is RIGHT JOIN, which returns ALL rows from the right table and matching rows from the left. Opposite of LEFT JOIN. More about this category: Table join operations — INNER, LEFT, RIGHT, FULL, CROSS, SELF JOIN.