qualifier : A qualifier. It can be omitted. When omitted, it is set to ALL.

ALL : Retrieves all records of the table.

DISTINCT : Retrieves only records with unique values without allowing duplicates. DISTINCT and DISTINCTROW are used interchangeably.

UNIQUE : Like DISTINCT, retrieves only records with unique values without allowing duplicates.

select_expression :

* : By using SELECT * statement, you can retrieve all the columns from the table specified in the FROM clause.

expression_comma_list : expression can be a path expression, variable or table name. All general expressions including arithmetic operations can also be used. Use a comma (,) to separate each expression in the list.
You can specify aliases by using the AS keyword for columns or expressions to be queried. Specified aliases are used as column names in GROUP BY, HAVING, ORDER BY and FOR clauses. The position index of a column is assigned based on the order in which the column was specified. The starting value is 1.
As AVG, COUNT, MAX, MIN, or SUM, an aggregate function that manipulates the retrieved data can also be used in the expression. As the aggregate function returns only one result, you cannot specify a general column which has not been grouped by an aggregate function in the SELECT column list.

table_name. * : Specifying the table name and using * has the same effect as specifying all columns for the given table.

variable : The data retrieved by the select_expression can be stored in more than one variables.

[:]identifier : By using the :identifier after TO (or INTO), you can store the data to be retrieved in the ':identifier' variable.

Example 1

The following example shows how to retrieve host countries of the Olympic Games without any duplicates. This example is performed on the olympic table of demodb.

The DISTINCT or UNIQUE keyword allows only unique values in the query result set. For example, when there are multiple olympic records whose host_nation values are 'Greece', you can use such keywords to display only one value in the query result.

SELECT DISTINCT host_nation FROM olympic;

host_nation

======================

'Australia'

'Belgium'

'Canada'

'Finland'

'France'

...

Example 2

The following example shows how to define an alias to a column to be queried and sort the result record by using the column alias in the ORDER BY clause. At this time, the number of the result records is limited to 5 by using the LIMIT clause and FOR ORDERBY_NUM().

SELECT host_year as col1, host_nation as col2 FROM olympic ORDER BY col2 LIMIT 5;