SQL — Inner Join
Basic INNER JOIN
SELECT users.name, orders.total
FROM users
INNER JOIN orders ON users.id = orders.user_id;
With table aliases
SELECT u.name, o.total
FROM users u
INNER JOIN orders o ON u.id = o.user_id;
Multiple joins
SELECT u.name, o.total, p.name AS product
FROM users u
INNER JOIN orders o ON u.id = o.user_id
INNER JOIN products p ON o.product_id = p.id;
INNER JOIN with WHERE
SELECT u.name, o.total
FROM users u
INNER JOIN orders o ON u.id = o.user_id
WHERE o.total > 100;
Self join
SELECT e.name AS employee, m.name AS manager
FROM employees e
INNER JOIN employees m ON e.manager_id = m.id;
Mini Practice
- Join two tables
- Use table aliases
- Join multiple tables
- Filter joined results
Up Next
Continue with Left Join - Left join operations.
Related Topics
Frequently Asked Questions about Inner Join
What is Inner Join in SQL?
Inner Join is a fundamental concept in SQL. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Inner Join?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Inner Join.
Why is Inner Join important in SQL?
Inner Join is essential for SQL development. Understanding this concept will help you write better code and solve real-world problems more effectively.