«Back to Home

Oracle Jump Start

Topics

How To Use Where Clause In Oracle

Description
 
Where clause is an optional part of a select statement, update statement or delete statement.
Boolean expression is allowed in the where clause.
 
Syntax
  1. Where condition; 
Example
 
In this example, use single condition.
 
Syntax
  1. Select  
  2. *  
  3. from  
  4. Table_name  
  5. where  
  6. column_name = ’ ’;  
Example
  1. Select  
  2. *  
  3. from  
  4. Employee  
  5. where  
  6. Emp_name = ’King’;  
5
 
Example
 
This example uses And condition.
 
Syntax
  1. Select  
  2. *  
  3. from  
  4. Table_name  
  5. where  
  6. column_name = ’ ’  
  7. AND Column_name condition;  
Example
  1. Select  
  2. *  
  3. from  
  4. Employee  
  5. where  
  6. Emp_name = ’Blake’  
  7. AND Emp_Id <= 7003;  
6 
 
Example
 
The example, stated below uses or condition.
 
Syntax
  1. Select  
  2. column_name  
  3. From  
  4. Table_name  
  5. where  
  6. column_name = ’ ’  
  7. Or Column_name = ’ ’;  
Example
  1. Select  
  2. Emp_id  
  3. from  
  4. Employee  
  5. where  
  6. Emp_name = ’King’  
  7. OR Emp_name = ’scott’;  
7 
 
Example
 
This example uses AND & OR condition.
 
Syntax
  1. Select  
  2. *  
  3. from  
  4. Table_name  
  5. where  
  6. (  
  7. column_name  
  8. AND Column_name  
  9. )  
  10. OR(Condition);  
Example
  1. Select  
  2. *  
  3. from  
  4. Employee  
  5. where  
  6. (  
  7. Emp_name = ’King’  
  8. AND Salary = ’60000’  
  9. )  
  10. OR(Emp_Id > 7004);  
8 
 
Summary
 
Thus, we learnt, Where clause is an optional part of a select statement, update statement or delete statement. Boolean expression is allowed in the where clause. We learnt, how to use this clause in Oracle with the examples.