By using table aliases described in section ,
you can refer to specific tables in the FROM clause using a shorter
name. Figure shows a rewrite of the query in figure
You can even join a table to itself using table aliases. Such joins are called
self-joins. The same table is given two different alias names. Each alias
then represents a different version of the table. This may seem like a concept
of questionable utility, but it can prove useful. Figure
shows practical examples.
The first query finds all customers in the same zipcode as customer number 648. The second finds all customers in the same zipcode as customer number 648, and then finds the order numbers placed by those customers. We have restricted the c2 table's customer id to not equal 648 because we don't want customer 648 to appear in the result. The third query goes farther by retrieving the part numbers associated with those orders.