The INNER JOIN is a commonly used operation in SQL to combine records from two or more tables based on a related column. It acts as a filter, returning only the rows where there is a match in both tables.
? Key Concepts
Joins multiple tables using a Common Column (usually Primary/Foreign Keys).
Returns only the Intersection of both datasets.
Data missing in either table for a specific ID will result in that row being excluded.
? Syntax / Theory
? View SQL Syntax
-- INNER JOIN syntax structure
SELECT table1.col, table2.col
FROM table1
INNER JOIN table2
ON table1.id = table2.fk_id;
? Code Example
Retrieve employee names with their corresponding department names.
? View Code Example
-- Joining employees and departments tables
SELECT employees.name, departments.dept_name
FROM employees
INNER JOIN departments
ON employees.dept_id = departments.id;
? Interactive Example
Try Joining These Tables
Table: Users
1. Alice (ID: 101)
2. Bob (ID: 102)
3. Charlie (ID: 103)