Understanding Self JOIN in MySQL
📖 Scenario: You work in a company database where employees have managers who are also employees. You want to find out who manages whom by linking employees to their managers.
🎯 Goal: Build a MySQL query using SELF JOIN to list employees alongside their managers' names.
📋 What You'll Learn
Create a table called
employees with columns id, name, and manager_idInsert the exact employee data with their manager IDs
Write a
SELECT query using SELF JOIN to get employee names and their managers' namesUse table aliases
e for employees and m for managers in the query💡 Why This Matters
🌍 Real World
Companies often store employee and manager data in the same table. Self joins help find relationships within the same dataset.
💼 Career
Understanding self joins is essential for database roles that involve hierarchical data, reporting structures, or organizational charts.
Progress0 / 4 steps