You can use the same table two (or more) times within a single query. There are several situations in which you do this.
By joining the table to itself using this reflexive relationship, you can establish a result set in which each row contains a bossÆs name and the name of one of that bossÆs employees. The resulting SQL might look like this:
SELECT
boss.lname,
boss.fname,
employee.lname,
employee.fname
FROM
employee
INNER JOIN
employee boss
ON employee.manager_emp_id
= boss.emp_id
SELECT
employee.fname,
employee.lname,
mentor.fname,
mentor.lname
FROM
employee
INNER JOIN
employee mentor
ON employee.job_lvl
< mentor.job_lvl
Notice that the join uses a condition other than equality.
SELECT
other_title.title
FROM
titles favorite_title
INNER JOIN
titleauthor favorite_titleauthor
ON favorite_title.title_id
= favorite_titleauthor.title_id
INNER JOIN
authors
ON favorite_titleauthor.au_id
= authors.au_id
INNER JOIN
titleauthor other_titleauthor
ON authors.au_id
= other_titleauthor.au_id
INNER JOIN
titles other_title
ON other_titleauthor.title_id
= other_title.title_id
WHERE
favorite_title.title
= 'Is Anger the Enemy?'
AND
favorite_title.title
<> other_title.title
Note To distinguish between the multiple uses of any one table, the preceding query uses the following aliases: favorite_title, favorite_titleauthor, other_titleauthor, and other_title.