SQLMentor // glossary

Inner Join

An inner join returns only the rows that have a match in both tables. Rows with no counterpart on either side are excluded from the result.

It is the default join type — writing JOIN means INNER JOIN. Use it when you only care about records that exist on both sides, such as employees who belong to a department that exists.

If you also need the non-matching rows (employees with no department, or departments with no employees), use a LEFT, RIGHT, or FULL OUTER JOIN instead.

Example

SELECT e.first_name, d.department_name
FROM   employees   e
INNER JOIN departments d ON e.department_id = d.department_id;