sqlself-joinrelational-algebra

What is a self-join for? (in English)


What would I seek to achieve from a self-join?

I already know what a self-join does. Operational descriptions on Stack Overflow with tables or join lists or the self-referencing employee-manager example do not help.

My usage is in a university course, from a Relational Algebra angle. I have done some SQL but the instructor loves to do self-joins (after renaming one or more fields). This is not something often done in SQL, so I'm wondering what he is trying to perform.


Solution

  • The reason why the employee-manager example is so common, is because it hits the nail on the head. A self join on a table looks for pairs of rows, like any join, but with both rows coming from the same table. Nothing special really.