| 
    Slide 14.10: The SELECT statement (cont.) Slide 14.12: The WHERE clause (cont.) Home  | 
  
    
   | 
 
WHERE Clause
 
WHERE clause is used to specify a selection criterion.
   
To conditionally select data from a table, a WHERE clause can be added to the SELECT statement.
   
   | 
  
   
  | 
 
WHERE clause, the following operators can be used:
| Operator | Description | Operator | Description | |
|---|---|---|---|---|
| = | Equal | <> | Not equal | |
| > | Greater than | < | Less than | |
| >= | Greater than or equal | <= | Less than or equal | |
BETWEEN | 
    Between an inclusive range | LIKE | 
    Search for a pattern | 
WHERE ClauseWHERE clause to the SELECT statement:| LastName | FirstName | Address | City | 
|---|---|---|---|
| Hansen | Ola | Timoteivn 10 | Sandnes | 
| Svendson | Tove | Borgvn 23 | Sandnes | 
| Pettersen | Kari | Storgt 20 | Stavanger | 
| Rasmussen | Storgt 67 | 
   SQL> select * from Persons where City = 'Sandnes'; LASTNAME FIRSTNAME ADDRESS CITY -------------- -------------------- -------------- ------------ Hansen Ola Timoteivn 10 Sandnes Svendson Tove Borgvn 23 Sandnes  | 
 
Customers table may be created by the following command:
   SQL> create table  Customers (
     2    CustomerID   varchar(16),
     3    CompanyName  varchar(32),
     4    ContactName  varchar(32),
     5    Address      varchar(64),
     6    City         varchar(32),
     7    PostalCode   varchar(16),
     8    Country      varchar(32) );
Note that the Customers table is for read only.