SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
S-20
SELECT Statement
FROM table-ref [ , table-ref ] ...
is a list of up to 16 tables, views, and join-tables (or equivalent DEFINEs),
each optionally qualified by a correlation name, that specifies the contents of an
intermediate table from which SQL retrieves the columns you specified in
select-list.
If you specify only one table-ref, the intermediate table consists of rows from
that table, view, or join-table. If you specify more than one table-ref, SQL
builds the intermediate table by logically concatenating each row of each table,
view, or join-table in the list with each row of every other table, view, or
join-table in the list. Within the intermediate table, tables and views are in the
order specified in the FROM clause; columns from each table or view are in the
order in which they exist in that table or view.
If table-ref is a grouped view, the view must be the only table-ref in the
FROM clause.
table-ref [ INNER ] JOIN table-ref ON search-cond
[ LEFT ]
specifies a join of a table, view, or join-table with another table, view, or
join-table.
If you specify LEFT JOIN, the table-ref on the right side of the keywords LEFT
JOIN (which is called the inner table of the join) cannot be a join-table or a
shorthand view whose definition is based on a join operation or on a union of
SELECT statements; the table-ref on the left cannot be a shorthand view
whose definition is based on a LEFT JOIN operation or on a union of SELECT
statements.
search-cond is the search condition for the join. Each column in the search
condition must be a column that exists in the intermediate table specified by the
FROM clause. If the search condition contains an expression list, the expression
list must be enclosed in parentheses, as shown:
TABLE1 JOIN TABLE2 ON (A,B) > (10,20)
For more information, see Joins on page J-1.
WHERE search-cond
specifies a search condition to apply to each row of the FROM clause result table.
Each column that you specify in search-condition must be a column in the
FROM clause result table.
INNER joins all rows that satisfy search condition.
LEFT joins all rows that satisfy search condition plus rows from table-ref
that do not.