Great for direct parent relationships like employee → manager.
Section: Hierarchy alternatives
Use self join for one-level hierarchy
text
text
One-level lookup: self join
Deep tree traversal: recursive CTEExplanation
A single self join handles immediate parent or sibling checks. For full ancestor paths, use recursive CTEs.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Hierarchy alternatives
Employee to manager self join
Resolve a manager relationship stored in the same table.
Find duplicate emails with self join
Compare rows in the same table using inequality to avoid mirrored duplicates.