WHERE Clause

Specifies which rows to include in a query's result set.

Syntax

WHERE boolean-expression [ subquery ]…

Parameters

boolean‑expression

An expression that returns true or false. The result set only includes rows that evaluate to true. The expression can include boolean operators and the following elements:

Use parentheses to group expressions, predicates, and boolean operators. For example:

… WHERE NOT (A=1 AND B=2) OR C=3;

Example

The following example returns the names of all customers in the Eastern region whose name starts with the string Amer:

=> SELECT DISTINCT customer_name
   FROM customer_dimension
   WHERE customer_region = 'East'
   AND customer_name ILIKE 'Amer%';
 customer_name
---------------
 Americare
 Americom
 Americore
 Americorp
 Ameridata
 Amerigen
 Amerihope
 Amerimedia
 Amerishop
 Ameristar
 Ameritech
(11 rows)