Recall & Review
beginner
What is a self join in SQL?
A self join is when a table is joined with itself to compare rows within the same table.
Click to reveal answer
beginner
Why use table aliases in a self join?
Aliases give different names to the same table so you can refer to it twice in the query clearly.
Click to reveal answer
intermediate
Example: How to find employees who have the same manager using self join?
Use a self join on the employee table matching manager_id to employee_id with aliases for clarity.
Click to reveal answer
intermediate
What is the difference between INNER JOIN and LEFT JOIN in self join patterns?
INNER JOIN returns only matching rows between the table and itself, LEFT JOIN returns all rows from the left side even if no match.
Click to reveal answer
advanced
How can self joins help in hierarchical data queries?
Self joins let you compare parent and child rows in the same table to explore hierarchy levels.Click to reveal answer
What keyword is essential to distinguish the same table twice in a self join?
✗ Incorrect
Aliases let you give different names to the same table so you can join it with itself.
In a self join, if you want all rows from the left table even if no match exists on the right, which join do you use?
✗ Incorrect
LEFT JOIN returns all rows from the left table and matches from the right or NULL if no match.
Which of these is a common use case for self joins?
✗ Incorrect
Self joins compare rows within the same table by joining it to itself.
What does the ON clause specify in a self join?
✗ Incorrect
The ON clause defines the condition to match rows between the two aliases of the same table.
If you want to find employees who share the same manager using a self join, which columns would you join on?
✗ Incorrect
You join employee.manager_id to manager.employee_id to find employees with the same manager.
Explain what a self join is and why table aliases are important in it.
Think about how you can use the same table twice in one query.
You got /3 concepts.
Describe a real-life example where a self join can be used to find relationships within the same data set.
Consider a company employee list with managers.
You got /3 concepts.