Course Content
🎁 Bonus Modules (Integrated Throughout)
Data Analytics
INNER, LEFT, RIGHT, FULL JOINS

In the real world, data is often spread across multiple tables. To make meaningful analysis, we need to connect or join these tables. SQL offers different types of joins, and each serves a different purpose based on how you want to combine the data.

 

Let’s break them down with practical understanding:


1. INNER JOIN: Finding Common Matches

This is the most common type of join. It returns only those records that have matching values in both tables.

 

  • Think of it like this: You have a list of customers and a list of orders. If you only want to see customers who have made orders, INNER JOIN will show only those.

 

 

Useful for: Reports, matched records, or when both sides must have data.


2. LEFT JOIN: Keep All from the Left Table

A LEFT JOIN returns all the records from the left table, and the matched records from the right table. If there’s no match, it still keeps the left table data and fills the rest with NULL (missing values).

 

  • Imagine: You want to see all customers, even those who haven’t placed any orders yet. LEFT JOIN will show them with “No Order” status.

 

 

Useful for: Finding “who hasn’t done something yet” or for showing all base data with optional related info.


3. RIGHT JOIN: Keep All from the Right Table

RIGHT JOIN is the mirror image of LEFT JOIN. It returns all records from the right table, and matched ones from the left table.

 

  • Scenario: You want to list all orders—even if some of those orders don’t yet have an assigned customer (e.g., guest checkout). RIGHT JOIN lets you capture those orphan records.

 

 

Useful for: Ensuring you don’t miss any entries from the second (right) table.


4. FULL JOIN: Everything from Both Sides

FULL JOIN (or FULL OUTER JOIN) returns all records from both tables, and fills in NULLs where there’s no match on either side.

 

  • Think of: A comprehensive report showing every customer and every order, including unmatched data—like customers who didn’t order and orders that don’t have linked customers.

 

 

Useful for: Data reconciliation, audits, and identifying unmatched entries.


Visual Summary (Analogy):
JOIN Type What It Shows
INNER JOIN Only those who are in both groups
LEFT JOIN Everyone from the left group + matching from right
RIGHT JOIN Everyone from the right group + matching from left
FULL JOIN Everyone from both groups, matched or unmatched
 
 

Conclusion

These joins are not just syntax tools—they are strategic methods to extract the exact slice of data you need for real-world reporting and decision-making. Whether you’re analyzing customer behavior, inventory status, or employee performance, joins help you connect the dots effectively.

0% Complete
WhatsApp Icon

Hi Instagram Fam!
Get a FREE Cheat Sheet on System Design.

Hi LinkedIn Fam!
Get a FREE Cheat Sheet on System Design

Loved Our YouTube Videos? Get a FREE Cheat Sheet on System Design.