Let us solve the query shown in Example 4.1.18: finding all pairs of instructors’ names for instructors who share the same office. This can be done by writing:
select I.name as firstname, INSTRUCTORS.name as secname from INSTRUCTORS I, INSTRUCTORS
where I.roomno = INSTRUCTORS.roomno and I.empno < INSTRUCTORS.empno;
The result of this query is:
FIRSTNAME SECNAME
------------------------------
Exxon George Will Samuel
Conceptually, we create an alias I of the table INSTRUCTORS, compute the product between this alias and INSTRUCTORS and retain those pairs that share the the same room and consist of distinct individuals.