Multi-table SELECT Statements

From InterBase
Jump to: navigation, search

Go Up to Listing Columns to Retrieve with SELECT


When data is retrieved from multiple tables, views, and select procedures, the same column name may appear in more than one table. In these cases, the SELECT statement must contain enough information to distinguish like-named columns from one another.

To distinguish column names in multiple tables, precede those columns with one of the following qualifiers in the SELECT clause:

  • The name of the table, followed by a period. For example,
    EMPLOYEE.EMP_NO identifies a column named EMP_NO in the EMPLOYEE table.
  • A table correlation name (alias) followed by a period. For example, if the correlation name for the EMPLOYEE table is EMP, then EMP.EMP_NO identifies a column named EMP_NO in the EMPLOYEES table.

Correlation names can be declared for tables, views, and select procedures in the FROM clause of the SELECT statement. For more information about declaring correlation names, and for examples of their use, see Declaring and Using Correlation Names.