#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
Step 9
4 min read

INNER JOIN

Learn how to combine data from two tables - explained simply.

What is INNER JOIN?

INNER JOIN combines rows from two tables only when they match.

Simple rule: No match = No show

How INNER JOIN Works

Basic Syntax

SELECT columns FROM table1 INNER JOIN table2 ON table1.id = table2.foreign_id;

Example 1: Students with Orders

SELECT students.name, orders.product FROM students INNER JOIN orders ON students.id = orders.student_id;

Result: Only John and Mary shown (Peter has no order)

Example 2: Using Aliases

SELECT s.name, o.product, o.amount FROM students s INNER JOIN orders o ON s.id = o.student_id;

Tip: Use s and o as short names (aliases)

Example 3: With WHERE Filter

SELECT s.name, o.product FROM students s INNER JOIN orders o ON s.id = o.student_id WHERE o.amount > 50;

INNER JOIN Rules

  1. Both must match - Row appears only if match exists in both tables
  2. No match = hidden - Unmatched rows are excluded
  3. Order matters - table1 INNER JOIN table2

Quick Comparison

  • INNER JOIN → Only matching rows
  • LEFT JOIN → All from left + matches
  • RIGHT JOIN → All from right + matches

Try It Below

Practice combining two tables with INNER JOIN!

What Comes Next

Next: LEFT JOIN - shows ALL from left table, even without match.

Finished this topic?

Mark it complete to track your progress and maintain your streak!