Each FROM TABLE specification (from_table_spec) in a FROM clause specifies either no table identifier, one table identifier, or any number of table identifiers.
<from_table_spec>
::= <table_name> [AS] [<reference_name>]
| <result_table_name> [AS] [<reference_name>]
| (<query_expression>) [AS] [<reference_name>]
| <joined_table>
table_name, reference_name, result_table_name, query_expression, joined_table
If a FROM TABLE specification does not contain a reference name, the table name (table_name) or result table name (result_table_name) is the table identifier.
If a FROM TABLE specification contains a reference name, the reference name is the table identifier.
Each reference name must be different from each identifier that specifies a table name. If a results table name is a table identifier, there must not be any table identifier <table_name> of the form [<owner.]<result_table_name> (the owner is the current user). Each table identifier must differ from any other table identifier.
The validity range of the table identifiers is the entire QUERY specification within which the FROM TABLE specification is used. If column names are to be qualified within the query specification, table identifiers must be used for this purpose.
Reference names are essential for formulating JOIN conditions within a table. For example, FROM HOTEL, HOTEL Xdefines a reference name X for the second occurrence of the HOTEL table. Reference names are also necessary sometimes to formulate correlated subqueries. Similarly, a reference name is required if a column in the result of a QUERY expression can only be identified uniquely by specifying the reference name.
If a from table specification denotes a base table, result table, or the result of a query expression, the number of tables underlying this from table specification is equal to 1.
If a from table specification denotes a complex view table, the number of tables underlying this from table specification is equal to 1.
If a from table specification denotes a view table that is not a complex view table, the number of underlying tables is equal to the number of tables underlying the FROM condition of the view table.
If a from table specification denotes a JOINED TABLE, the number of tables underlying this from table specification is equal to the total number of underlying tables of the FROM TABLE specifications contained in it.
A FROM TABLE specification that contains a QUERY expression specifies a table identifier only if a reference name is specified.
If a FROM TABLE specification contains a QUERY expression, a result table is built that matches this QUERY expression. This result table obtains a system-internal name that collides neither with an unnamed nor a named result table. While the from condition is being processed, the result of the query expression is used in the same way as a named result table and is deleted implicitly after processing.
A table expression containing at least one OUTER JOIN indicator (see JOIN predicate) or OUTER JOIN TYPE (LEFT | RIGHT | FULL) (see joined_table) is subject to strict restrictions if it is to be based on more than two tables. For this reason, a QUERY expression is frequently required to formulate a QUERY specification that is to be based on at least three tables and in which at least one OUTER JOIN indicator is used in a JOIN predicate.
A from table specification containing a JOINED TABLE (joined_table) specifies the number of table identifiers that are specified by the FROM TABLE specifications it contains.