Previous Topic: OPEN StatementNext Topic: UPDATE Statement


SELECT Statement

The SELECT statement extracts data from a relational table that meets the criteria you specify. You can use the SELECT statement by itself or within another statement (then called a subquery).

Syntax

LSQL SELECT columnlist|*asterisk [INTO (hostvarlist)] FROM tablename
 [WHERE criteria] [GROUP BY criteria [HAVING criteria]] [ORDER BY criteria]

Parameters

*

Selects all columns in a table.

columnlist

Selects the values only from the columns you name. Separate each column name by a comma.

criteria

Search criteria that you are using to match values in the specified columns.

FROM

Clause that is used to specify the tablename from which data is being selected.

GROUP BY

Clause that is used to summarize multiple rows of data into single rows that are based on the specified criteria.

HAVING

Clause used, only with a GROUP BY clause, to limit further the output of the statement that is based on the specified criteria.

hostvarlist

Host variables in which to store the selected column values. In a cursor declaration, do not use this parameter because this function is accomplished with the FETCH statement.

ORDER BY

Clause that is used to specify the order of the statement output.

tablename

Name of the relational table from which you are selecting.

Notes:

Examples