command-query

Returns data from one or more tables

Format

query-expr [, UNION query-expr ]*

[ ORDER BY sort-spec [, sort-spec ]* ]

Remarks

Executes a query returning data from one or more tables. Refer to query-expr for details on the query expression (SELECT) clause.

The UNION operator allows multiple query expressions to be combined into a single table.

The optional ORDER BY sorts the combined result set. Columns referenced by the sort clauses must be present in the result set.

Example:

SELECT FullName, CurrentStateDesc, CurrentTime FROM CPointAlg UNION

SELECT FullName, StateDesc, "Time" FROM CDBPointSource

ORDER BY 3

Any number of queries may be combined and an ORDER BY may follow to sort the combined results.

By default duplicate results are removed, UNION may optionally be followed by ALL to retain duplicates:

SELECT FullName, CurrentStateDesc, CurrentTime FROM CPointAlg UNION ALL

SELECT FullName, StateDesc, "Time" FROM CDBPointSource

ORDER BY 3

Parentheses are not needed to remove any ambiguity over the other use of the UNION operator.

The UNION operator has the following restrictions:


Disclaimer

Geo SCADA Expert 2019