This guide is specifically for PostgreSQL syntax.
Advanced-level SQL INNER JOIN practice exercises with solutions.
Exercise 1
Question: List employees with their manager's name using a self-join.
SELECT e.name AS employee, m.name AS manager FROM employees e INNER JOIN employees m ON e.manager_id = m.id;
A self-join joins a table to itself. Use different aliases to distinguish between the two instances of the same table.
PostgreSQL-Specific Notes
This page covers PostgreSQL syntax. Other databases may have different syntax for similar operations.