Header Ads

Header ADS

Using the WHERE Clause

Using the WHERE Clause In Oracle SQL

Topic Introduction: In this tutorial, we will discuss Using the WHERE Clause in Oracle SQL. Previously, we had learned about the three capabilities of SQL SELECT Statements. 1. Projection, 2. Selection, and 3. Join. Today we will discuss the second-term Selection by which we can limit rows using the Where clause.

we use the where clause to restrict data from tables.  In this clause we write one or more conditions to get the targeted row, it can be a specific id, name, set, number range, Date Range, and any more type of condition.


Example:

select employee_id,last_name,hire_date,salary,department_id
from employees
where department_id=90
and last_name like '%King%'
and hire_date between '01-JAN-03' and '31-DEC-03'
and salary between 20000 and 25000;


We have used four conditions in this query to get the desired result. first the WHERE then AND.
1. where department_id=90 in this condition we want to see the employee details of 90 no Department.
2. and last_name like '%King%' in this condition we specify that we want the employee list whose last name with King.
3. and hire_date between '01-JAN-03' and '31-DEC-03' This condition specifies that the employee list who joined between 01-JAN-03 to 31-DEC-03 means in the 2003 year
4. and salary between 20000 and 25000 that specify salary range will be 20000 to 25000.

Note 1. If characters or dates are used in the condition values, they must be enclosed with single quotation marks ('').

No comments

Theme images by Deejpilot. Powered by Blogger.