WHERE Clause
The WHERE clause specifies criteria that restrict the contents of the results table. You can test for simple relationships or, using subselects, for relationships between a column and a set of columns.
Using a simple WHERE clause, the contents of the results table can be restricted, as follows:
Comparisons:
SELECT ename FROM employee_dim
WHERE manager = 'Al Obidinski';
SELECT emp_name FROM employee_dim
WHERE salary > 50000;
Ranges:
SELECT ordnum FROM orders
WHERE odate BETWEEN DATE('2014-01-01') AND CURRENT_DATE;
Set membership:
SELECT * FROM orders
WHERE partno IN ('123-45', '678-90');
Pattern matching:
SELECT * FROM employee_dim
WHERE emp_name LIKE 'A%';
Nulls:
SELECT emp_name FROM employee_dim
WHERE dept_no IS NULL;
Combined restrictions using logical operators:
SELECT emp_name FROM employee_dim
WHERE dept_no IS NULL AND
hiredate = CURRENT_DATE;
Note: Aggregate functions cannot appear in a WHERE clause.
More information: