SELECT command

Syntax

SELECT [ALL | DISTINCT ] select_list
   FROM [table_name | subquery] (corr_name)
      (, [table_name | subquery] (corr_name)) ...
   (WHERE search_condition)
   (GROUP BY column_name (, column_name) ...)
   (HAVING search_condition)
   (ORDER BY {column_name | select_list_number } (ASC | DESC)) ...
Keyword Description
select_list List of columns to retrieve
table_name Name of table or tables in which the columns reside
correlation_name Also called range variable or alias, provides an alternative name for the table whose name it follows; the definition lasts only for the duration of the statement. Correlation names are optional for base tables and views, but required for tables produced by subqueries
search_condition Criteria by which you identify rows on which you want to act
column_name Name of the column to evaluate with the search_condition
select_list_number Position in the select list of the column to evaluate with the search_condition

Use

This is the statement used to formulate queries, which are requests for information from the database. To issue this statement, you must have the SELECT privilege on all tables accessed. Queries may be stand-alone or used in the definitions of views and cursors. In addition, you can use them as subqueries to produce values that are used within other statements, including the SELECT statement itself. Sometimes a subquery is evaluated separately for each row processed by the outer query. Values from that outer row are used in the subquery. Queries of this type are called "correlated subqueries."

The output of a query is itself a table, and the SELECT clause defines the columns of that table (the output columns).

Clauses of the SELECT statement are evaluated in the following order:

  1. FROM
  2. WHERE
  3. GROUP BY
  4. HAVING
  5. SELECT
  6. ORDER BY*
Note: The order of records returned by Micro Focus XDBC is always undefined unless you specify an ORDER BY clause. If a specific returning order is required, you must use the ORDER BY clause.