एक self-join एक join हो जहाँ एक table आफैलाई join गरिन्छ — यो उपयोगी हुन्छ जब table मा rows अरू rows सँग सम्बन्धित हुन्छन् एउटै table मा, जस्तै hierarchies (कर्मचारी र तिनीहरूका प्रबन्धकहरू) वा table भित्र rows तुलना गर्ने समयमा।
क्लासिक उदाहरण: कर्मचारी र प्रबन्धकहरू
employees table — manager_id references another employee's id (in the SAME table):
id | name | manager_id
1 | Ann | NULL (Ann is the boss)
2 | Bob | 1 (Bob's manager is Ann)
3 | Carol | 1 (Carol's manager is Ann)
e.name employee, m.name manager
employees e
employees m e.manager_id m.id;
