What is the difference between a left join and a right join?
💡 Model Answer
A left join (or left outer join) returns all rows from the left table and the matching rows from the right table. If there is no match, the right side columns are NULL. A right join (or right outer join) does the opposite: it returns all rows from the right table and the matching rows from the left table, filling NULLs on the left side when there is no match. The key difference is which table's rows are guaranteed to appear in the result set. In practice, a left join is often used when the left table is the primary source of data, and you want to preserve all its rows. A right join is used when the right table is the primary source. In many SQL engines, you can rewrite a right join as a left join by swapping the table order, so the choice is largely syntactic.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500