0
0
SQLquery~5 mins

Self join concept in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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 do we use table aliases in a self join?
Table aliases give different names to the same table so we 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 employee.manager_id with manager.employee_id using aliases.
Click to reveal answer
intermediate
Can a self join be used with INNER JOIN and LEFT JOIN?
Yes, self joins can use INNER JOIN, LEFT JOIN, or other join types depending on the data needed.
Click to reveal answer
beginner
What is the main difference between a self join and a regular join?
A self join joins a table to itself, while a regular join combines two different tables.
Click to reveal answer
What does a self join do?
AJoins a table to itself
BJoins two different tables
CJoins two databases
DJoins two columns in the same table
Why are aliases important in a self join?
ATo rename columns
BTo speed up the query
CTo create new tables
DTo refer to the same table twice clearly
Which join type can be used in a self join?
AAny join type like INNER JOIN or LEFT JOIN
BOnly LEFT JOIN
COnly INNER JOIN
DNo join type is needed
In a self join, what does the ON clause usually compare?
ATwo different tables' columns
BTwo unrelated columns
CTwo columns from the same table using aliases
DTwo databases
What is a common use case for a self join?
ACombining sales data from two tables
BFinding employees with the same manager
CJoining customer and order tables
DCreating a new table
Explain what a self join is and why we use table aliases in it.
Think about how you can compare rows in the same table.
You got /3 concepts.
    Describe a real-life example where a self join would be useful.
    Consider relationships within one group of people.
    You got /3 concepts.