Полезная информация

next up previous contents index
Next: Joined Tables Up: Joining Tables Previous: Joining Tables

Table and Column References

 Before dealing with joins, there is one important feature that must be mentioned. Up to this point, all queries have involved a single table. With multiple tables in a query, column names get confusing. Unless you are familiar with each table, it is difficult to know which column names belong to which tables. Sometimes two tables have the same column name. For these reasons, SQL allows you to fully qualify column names by preceeding the column name with the table name. An example of table name prefixing is shown in figure [*].

  
Figure: Qualified column names
\begin{figure}\begin{list}{}{
\setlength{\rightmargin}{\leftmargin}
\raggedrigh...
...-{}-{}-{}-{}-{}-{}-
\par Victor~~~~~~~~~
\par (1~row)\end{list}\par
\end{figure}

First, a query with unqualified column names. Second, the same query with fully qualified column names. A period separates the table name from the column name.

The final query shows another feature. Instead of specifying the table name, you can create a table alias to take the place of the table name in the query. The alias name follows the table name in the FROM clause. In this example, f is used as an alias for the friends table. While these features are not important in single table queries, they are useful in multi-table queries.


next up previous contents index
Next: Joined Tables Up: Joining Tables Previous: Joining Tables
Bruce Momjian
1999-11-21