What are SQL joins and how do INNER, LEFT, RIGHT, FULL differ?
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.
Related Interview Questions
Describe a PRIMARY KEY and how it differs from a UNIQUE key
Medium
What is ER model in the DBMS?
Medium
FlipkartWhat is the difference between LIKE and equals operators in SQL?
Easy
TCSWhat is the difference between UNION and UNION ALL?
Easy
What is Join and explain its types?
Medium
FlipkartWhat is the ER model in DBMS?
Easy
Flipkart