SQL WHERE Clause
SQL > SQL Commands >
We can use the WHERE clause to filter the result set based on certain conditions. The syntax for using WHERE in the SELECT statement is as follows:
"Condition" can include a single comparison clause (called simple condition) or multiple comparison clauses combined together using AND or OR operators (compound condition).
Example 1: WHERE Clause With Simple Condition
To select all stores with sales above $1,000 in Table Store_Information,
we key in,
WHERE Sales > 1000;
Example 2: WHERE Clause With OR Operator
To view all data with sales greater than $1,000 or with transaction date of 'Jan-08-1999', we use the following SQL,
WHERE Sales > 1000 OR Txn_Date = 'Jan-08-1999';
Using WHERE With UPDATE and DELETE
In addition to the SELECT statement, the WHERE clause can also be used with UPDATE and DELETE statements. Examples of how to use the WHERE clause with these two commands can be seen in the UPDATE and DELETE sections.