Relational Operators OR Comparison operators


Relational operators (OR) Comparison operators:

Relational Operators are used to check conditions that compares one expression with another. The result of the comparison can be TRUE, FALSE or UNKNOWN. 

Below are different types of comparison operators.

1. Equal to ( = )

2. Greater than ( > )

3. Less than ( < )

4. Greater than equal to ( >= )

5. Less than equal to ( <= )

6. Not equal to ( <> )

Equal to ( = ) operator:

The equal to operator is used to check the equality test with in two numbers or expression.
For example assume, We have a table called "employee" and it have columns 'Salary' and 'Bonus'.
Below query is used to fetch the details where salary is equal to 20000.

SQL> Select * from employee where salary =20000;

Greater than ( > ) Operator:

Greater than operator is used to test whether a number is greater than other one.

Suppose assume If we want to fetch the employee details whose salary is greater than 20000.

SQL> Select * from employee where salary>20000;

Less than( < ) Operator: 

Less than operator used to test the whether a number is less than other one.

Below query is used to fetch the employee details whose salary is less than 20000.

SQL> Select * from employee where salary < 20000;

Greater Than equal to (>=) operator :

This is almost same like greater than operator. Used to fetch the greater and equal values.

SQL> Select * from employee where salary >= 20000;

This is used to fetch employees details where the salary is equal to 20000 and greater also.

Less than equal to ( <= ) operator : 

This is same like less than operator where this is used to fetch less and equal to the specified value.

SQL> Select * from employee where salary <= 20000;

So the above query fetches all the employee details whose salary is less and equal to 20000.


Not Equal to ( < > ) operator :

This is used to fetch the values other than the specified values in the condition.

SQL> select * from employee where salary <> 20000;

The above query is used to fetch all the employee details other than 20000 salary employees.



                                                    Thank You

Comments