</>
Skip to content
SQL lessons (29/54)

SQL — Self 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

  1. Join two tables
  2. Use table aliases
  3. Join multiple tables
  4. Filter joined results

Up Next

Continue with Left Join - Left join operations.

Related Topics

Frequently Asked Questions about Self Join

What is Self Join in SQL?

Self 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 Self 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 Self Join.

Why is Self Join important in SQL?

Self Join is essential for SQL development. Understanding this concept will help you write better code and solve real-world problems more effectively.