PrepZone Logo
PrepZone
Back to Database

Database · Easy

What is a self join and when do you need one?

DatabaseSQLFresher

Answer preview

A self join is a join of a table to itself using two different aliases. You need it when a relationship lives inside one table — a hierarchy (employees.manager_id pointing at employees.emp_id) or a comparison between two rows of the same set.…