Skip to content
RED SAGSkills
easyDatabase Administrator interview question

Explain the main SQL join types and give an example of when you would use each.

What the interviewer wants to hear

  • INNER JOIN returns only matching rows from both tables
  • LEFT JOIN keeps all rows from the left table, with NULLs where nothing matches
  • RIGHT and FULL OUTER JOIN keep unmatched rows from the right or both sides
  • CROSS JOIN returns every combination of rows
  • Join columns should normally be indexed

Model answer

An INNER JOIN returns only rows that have a match in both tables, for example orders with their customer details. A LEFT JOIN keeps every row from the left table and fills the right side with NULLs when there is no match, so I use it for questions like "all customers and their orders, including customers who never ordered", or with WHERE right.id IS NULL to find customers with no orders. A RIGHT JOIN is the mirror image, and most people just swap the tables and use LEFT. A FULL OUTER JOIN keeps unmatched rows from both sides, which is useful when reconciling two data sources. A CROSS JOIN returns every combination, for example generating all dates for every store. For performance, the join columns, especially foreign keys, should usually be indexed.

Can you answer it under time pressure?

Take a timed easy round and get scored on every answer.

Start mock interview

More easy Database Administrator questions