Operators In SQL
Operators: SQL
generally contains some reserved words that are used to perform operations such
as Arithmetical, Comparison and Logical Operations etc. These reserved words
are known as Operators.
Generally, there are three types of operators in SQL:
i. SQL Arithmetic Operators
ii. SQL Comparison Operators
iii. SQL Logical Operators
SQL Arithmetic Operators
Let assume
variable A holds 20 and variable B holds 60 then:
Operators |
Description |
|
Example |
|
+ |
Add |
|
A+B= will give 80 |
|
- |
Subtract |
|
A-B= will give -40 |
|
* |
Multiply |
|
A*B= will give 1200 |
|
/ |
Division |
|
B/A= will give 3 |
|
% |
Modulo |
|
B%A= will give 0 |
SQL Comparison Operator
Let assume
variable A holds 20 and variable B holds 60 then:
Operators |
Description
|
|
Example |
= |
Examines
both operands value that are equal or not, if yes condition becomes true. |
|
A=B is not true |
!= |
This is used to check the value
of both operands are equal or not, if not condition become true. |
|
A!=B is true |
<> |
Examines
the operands value equal or not, if not condition become true. |
|
A<>B is true |
> |
Examines the left operand value
is greater than right operand, if yes condition becomes true. |
|
A>B is not true |
< |
Examines
the left operand value is less than right operand, if yes condition becomes
true |
|
A<B is true |
>= |
Examines that the value of left
operand is greater than or equal to the value of right operand or not, if yes
condition become true. |
|
A>=B is not true |
<= |
Examines that the value of left
operand is less than equal to the value of right operand or not, if yes
condition become true. |
|
A<=B is true |
SQL Logical Operators
Operators |
|
Description |
|
|
AND |
|
Return
true if both expressions are true. |
|
|
OR |
|
Return true if either
expression is true. |
|
|
NOT |
Reverse the result of any
other Boolean operator. |
|
||
LIKE |
|
Return true if the operand
matches a pattern. |
|
|
BETWEEN |
Return true if the
operand is within a range. |
|
Comments
Post a Comment