EasyJOINs (INNER, LEFT, RIGHT, FULL)

Join employees with departments to get location

The query

SQL
SELECT
  e.first_name,
  e.last_name,
  e.job_title,
  d.dept_name,
  d.location
FROM employees e
JOIN departments d ON e.dept_id = d.dept_id
WHERE d.location = 'Bangalore'
ORDER BY e.last_name;
Tested against PostgreSQL 16

Note

Adding WHERE after JOIN filters the combined result. Works on any column from either table.

Tables referenced