4.4.6 WHERE clause

Organization of this subsection
(1) Format
(2) Function
(3) Operands
(4) Syntax rules
(5) Notes
(6) Usage example

(1) Format

WHERE-clause::=WHERE[Figure]search-condition

(2) Function

Specifies a search condition for the relation returned by the FROM clause.

If the WHERE clause is specified without the HAVING clause, the relation returned by the WHERE clause becomes the target of the SELECT clause.

If there is no WHERE clause, all rows in the relation returned by the FROM clause become the targets of the SELECT clause.

(3) Operands

search-condition

For details about specifying a search condition, see 4.4.17 Search condition.

If the preceding FROM clause contains only one relation reference, only a column name needs to be specified for the search condition. If the FROM clause contains multiple relation references, you must specify a data identifier and a column name for each column specified in the search condition to make the column names unique.

(4) Syntax rules

If t is used to denote the relation returned by the preceding FROM clause, the search condition applies to each row in t. The relation returned by the WHERE clause consists of a subset of the rows in t for which the search condition is true.

(5) Notes

The relation returned by the WHERE clause is a single group without grouped columns.

(6) Usage example

Outputs the data in columns a and b if the value of column b in relation s1 is greater than 10. The underlined part indicates the WHERE clause.

REGISTER QUERY q1 SELECT s1.a,s1.b FROM s1[ROWS 100] WHERE s1.b > 10;