Previous Topic

Next Topic

SELECT

Description

Selects the specified column values from one or more rows contained in the table(s) specified in the FROM clause. The selection of rows is restricted by the WHERE clause. The temporary table derived through the clauses of a select statement is called a result table.

The format of the SELECT statement is a query expression with optional ORDER BY and FOR UPDATE clauses. For more detail on query expressions, see "Query Expressions".

Syntax

select_statement ::
   query_expression
   ORDER BY { expr | posn } [ ASC | DESC ]
[ , { expr | posn } [ASC | DESC] , ]
   FOR UPDATE [ OF [table].column_name,  ] [ NOWAIT ];
query_expression ::
    query_specification
|   query_expression set_operator query_expression
|   ( query_expression )

set_operator ::
     {  UNION [ ALL ]  |  INTERSECT  |  MINUS }
query_specification ::
SELECT [ALL | DISTINCT | [TOP n]
        {
           *
        |  { table_name | alias } . * [, { table_name | alias } . * ] …
        |  expr [ [ AS ] [ ' ] column_title [ ' ] ] [, expr [ [ AS ] [ ' ] column_title [ ' ] ] ] 
        }
FROM table_ref [ { ctree ORDERED } ] [ , table_ref [ { ctree ORDERED } ] …
[ WHERE search_condition ]
[ GROUP BY [table.]column_name
                  [, [table.]column_name ] …
[ HAVING search_condition ]

table_ref ::
           table_name [ AS ] [ alias [ ( column_alias [ , … ] ) ] ]
        |  ( query_expression ) [ AS ] alias [ ( column_alias [ , … ] ) ]
        |  [ ( ] joined_table [ ) ]

joined_table ::
           table_ref CROSS JOIN table_ref
        |  table_ref [ INNER | LEFT [ OUTER ] ] JOIN table_ref ON search_condition  

Arguments

query_expression

See "Query Expressions".

ORDER BY clause
See "ORDER BY CLAUSE".

FOR UPDATE clause

Note: Use of ODER BY in a FOR UPDATE clause is a non-standard SQL feature as specified by SQL92. Also, full cursor update is not supported by c-treeACE SQL.
See "UPDATE".

Authorization

The user executing this statement must have any of the following privileges:

  • DBA privilege
  • SELECT permission on all the tables/views referred to in the query_expression.

    SQL Compliance

    SQL-92. Extensions: FOR UPDATE clause. ODBC Extended SQL grammar.

    Environment

    Embedded SQL (within DECLARE), interactive SQL, ODBC applications

    Related Statements

    Query Expressions, DECLARE CURSOR, OPEN, FETCH, CLOSE