WHERE Clause

Eliminates rows from the result table that do not satisfy one or more predicates.

Syntax

WHERE boolean-expression [ subquery ]…

Parameters

boolean-expression

Is an expression that returns true or false. Only rows for which the expression is true become part of the result set.

The boolean-expression can include boolean operators and the following elements:

Notes

You can 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 'Amer'. Without the WHERE clause filter, the query returns all customer names in the customer_dimension table.

=> 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)