</>
ShikshaCSLearn. Code. Grow.
🔍
☕ Support Us
ShikshaCSâ€ēNotesâ€ēDatabase Management Systems
Database Management Systems
🕒 8 min read

SQL Joins Explained

Combining rows from two or more tables — the most-used SQL skill.

INNER JOIN

Returns only rows that have matching values in both tables. If a row in Table A has no match in Table B, it's excluded from the result.

SELECT s.name, c.course_name
FROM students s
INNER JOIN courses c ON s.course_id = c.id;

LEFT JOIN

Returns all rows from the left table, plus matched rows from the right table. Unmatched right-side columns show as NULL — useful when you want to keep every record from your main table.

RIGHT JOIN & FULL JOIN

RIGHT JOIN mirrors LEFT JOIN but keeps all rows from the right table instead. FULL JOIN keeps all rows from both tables, matching where possible and filling NULLs where there's no match.

🌍 Real-World Use

An admin dashboard showing 'all students and their enrolled courses, including students with no course yet' uses a LEFT JOIN — this is one of the most common real-world join patterns you'll write on the job.

💡 Pro Tip

Draw a Venn diagram mentally (or on paper during an interview) for each join type — it's the fastest way to explain and remember exactly which rows get included or excluded.

đŸ§Ē Quick Self-Test

Check what you just learned — no pressure, just practice.

1. Which join returns only matching rows from both tables?

2. In a LEFT JOIN, what happens to unmatched right-table columns?

← Back to all Notes