EasyJOINs (INNER, LEFT, RIGHT, FULL)

INNER JOIN: employees with their department names

The query

SQL
SELECT
  e.emp_id,
  e.first_name,
  e.last_name,
  d.dept_name,
  d.location
FROM employees e
INNER JOIN departments d ON e.dept_id = d.dept_id;
Tested against PostgreSQL 16

Note

INNER JOIN returns only rows with matching values in BOTH tables. Most common join type.

Tables referenced