8. SQL Statements : SELECT (interactive) : Select Statement Clauses : WHERE Clause
 
Share this page                  
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 emp_name FROM employee
       WHERE manager = 'Jones';
SELECT emp_name FROM employee
       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
       WHERE emp_name LIKE 'A%';
Nulls:
SELECT emp_name FROM employee
       WHERE dept_no IS NULL;
Combined restrictions using logical operators:
SELECT emp_name FROM employee
       WHERE dept_no IS NULL AND
       hiredate = CURRENT_DATE;
Note:  Aggregate functions cannot appear in a WHERE clause.