What are SQL joins and how do INNER, LEFT, RIGHT, FULL differ?

SQL
Medium
130.9K views

This question covers the core mechanism of combining tables. It assesses proficiency in retrieving related data.

Why Interviewers Ask This

Joins are fundamental to relational databases. Interviewers test if you can combine data from multiple sources correctly. They also evaluate your ability to choose the right join type for specific business requirements.

How to Answer This Question

Define joins as combining rows based on matching conditions. Briefly explain INNER (matches only), LEFT (all left + matches), RIGHT (all right + matches), and FULL (all rows). Emphasize what happens to non-matching rows in each case.

Key Points to Cover

  • Combines tables via conditions
  • INNER returns intersection
  • LEFT keeps all left rows
  • FULL keeps all rows

Sample Answer

SQL joins combine rows from two tables based on a matching condition. An INNER JOIN returns only matches existing in both tables. A LEFT JOIN returns all rows from the left table and matching rows from the right, filling NULLs where no match exists. A RIGHT JOIN is the mirror image, and a FULL OUTER JOIN returns all rows from either table.

Common Mistakes to Avoid

  • Mixing up LEFT and RIGHT
  • Forgetting NULL behavior in outer joins
  • Confusing CROSS JOIN with INNER

Practice This Question with AI

Answer this question orally or via text and get instant AI-powered feedback on your response quality, structure, and delivery.

Start Practicing

Related Interview Questions

Browse all 49 SQL questions