Show TOC

Syntax documentationSELECT Statement Locate this document in the navigation structure

Use

A SELECT statement allows retrieving data from the database. Technically, it is a query with an optional clause for ordering the results. The query is either a query specification or a union of query specifications. The result of a SELECT statement is a result set.

Syntax Syntax

  1. <select statement> ::= <query> ( <order by clause> )?.
    
    <query>  ::= <query specification>
                        | <query expression>
    
End of the code.

Example Example

  1. SELECT * FROM employees
End of the code.

A Simple SELECT Statement. This SELECT statement selects all columns from the table employees.

Example Example

  1. SELECT empid AS employee_id, last_name,salary 
                             FROM employees 
                             WHERE salary>5000 
                             ORDER BY employee_id
    
End of the code.

A SELECT Statement. This SELECT statement selects data from the columns empid, last_name and salary from the table employees. The statement selects only the employees whose salary is greater than 5,000. In the result table, the data from the empid column is presented in a column named EMPLOYEE_ID, and the table is sorted by this column in ascending order.