Command SELECT - SQL Foundation
Retrieves data from one or more tables
SELECT [DISTINCT][*|ALL] <ColumnExpression> [AS <cAliasName>] [,...] FROM <SelectSource> [AS <cAliasName>] [,...] [INNER|LEFT [OUTER]|RIGHT [OUTER]|FULL [OUTER]] JOIN <cTableName> ON <JoinExpression> | USING <cFieldName> [, <cFieldName>] ] [WHERE <FilterExpression> | <JoinExpression>] [GROUP BY <Expression> [HAVING <FilterExpression>] [UNION [ALL]|INTERSECT|EXCEPT] <SubSelectExpression>] [ORDER BY <Expression> [ASC|DESC] [, <Expression> [ASC|DESC]]] [LIMIT <nExpression> [OFFSET <nExpression>] [VIA (coSession)] [INTO [CURSOR] <cAlias> |INTO ARRAY <aResult> |INTO OBJECTS <aResult> [CLASS <coClassName>] |EVAL <cbExpression> ] |INTO VALUE <xResult> [INTO TABLE <cResultTableName> [VIA <cResultDbeName>]]
The SQL SELECT command retrieves rows from one or more tables. The general processing performed by SQL SELECT is as follows:
1.) All elements in the FROM list are computed. Each element in the FROM list is a real or virtual table. If more than one element is specified in the FROM list, they are cross-joined together.
2.) If the WHERE clause is specified, all rows that do not satisfy the condition are eliminated from the output.
3.) If the GROUP BY clause is specified, the output is combined into groups of rows that match on one or more values. If the HAVING clause is present, it eliminates groups that do not satisfy the given condition.
4.) The actual output rows are computed using the SELECT output expressions for each selected row or row group.
5.) SELECT DISTINCT eliminates duplicate rows from the result. SELECT ALL (the default) returns all candidate rows, including duplicates.
6.) Using the operators UNION, INTERSECT, and EXCEPT, the output of more than one SELECT statement can be combined to form a single result set.
7.) If the ORDER BY clause is specified, the returned rows are sorted in the specified order. If ORDER BY is not given, the rows are returned in whatever order the system finds fastest to produce.
8.) If the LIMIT or OFFSET clause is specified, the SELECT statement only returns a subset of the result rows.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.