A0

Labels

More operators, order, between, in, like and where clause

 



In this blog we will talk about some more operators which we can use in oracle SQL e.g not, or, and, >=, <=, <, >, =, <> etc. These are some more operators and how we can use them now we will understand this.

Before learning about these operators we should understand about where clause. As this name is showing the qualities of this clause that it uses when we want to filter the result also this we can use only with the select statement. Example to use this clause is given below

select ename from emp where empid=2;

Meaning: Meaning of this query is to find the employee name from employee table where employee if is equal to 2.

Use of the operators:

select ename, sal from emp where sal>2000;

select ename, sal from emp where sal<2000;

select ename, sal from emp where sal>=2000 or sal<=2000;

select ename, sal from emp where sal<>1000; (Not equal to operator)

This is how we can use these operators. There are also lot of the things which we can perform in oracle SQL.


Order:

We can also show the result in ascending or descending order and how we can use this is given below

select ename, sal from emp order by ename asc; (result will show alphabetically) 

ascending order oracle sql


select ename, sal from emp order by ename desc; (result will be show in descending order)



You can also check the result by copy the query and paste that queries to the SQL plus. 


Between, in, like:

As the name showing the meaning that between is uses to show the result between two inputs, In uses as or operator and like is uses to show the similar result for like. How we can use this examples are given below

1) select ename, sal from emp where sal between 1000 and 500; (this will show the salaries which are between 1000 and 500)

2) select ename, sal from emp where empid in(1,2,3); (this will show the ename and salaries for empid's which are 1, 2 or 3;

3) select * from emp where ename like'%R'; (this will show the results where enames end with R)

More about Like:

There are more things which are necessary to understand about the like operator so there are below

like'%R%'; (this will display the result for enames where names contain R in the center)


















0 Comments:

Post a Comment