SQL Operators:
1)Arithmetic Operators
2) Comparison
Operators
3)Logical (or) Relational Operators
1) Arithmetic Operators:
Operator
|
Description
|
Example
|
+
|
Addition – Adding values on either side of the
operator. If a=10 and B=20 then
|
a + b will gives 30
|
_
|
Subtraction - Subtracts right hand operand from left
hand operand
If
a=10 and B=20 then
|
a - b will gives -10
|
*
|
Multiplication - Multiplies values on either side
of Operator
If a=10 and B=20 then
|
a * b will give 200
|
/
|
Division - Divides left hand operand by right
hand operand
If a=10 and B=20 then
|
b/a=2
|
%
|
Modulus - Divides left hand operand by right hand
operand and returns remainder
|
b % a will give 0
|
2) Comparison Operators:
operator
|
Description
|
Example
|
=
|
Check if the values of two operands
are equal or not, if yes then condition becomes true. If a=10 and B=20 then
|
(a=b) is not true
|
!=
|
Check if the values of two operands are equal or not, if values are
not equal then condition becomes true.
|
(a ! = b) is true.
|
<>
|
Check if the values of two operands are equal or not, if values are
not equal then condition becomes true.
|
(a<>b) is true
|
>
|
Checks if the value of left operand is greater than the value of
right operand, if yes then condition becomes true.
|
(a > b) is not true.
|
<
|
Checks if the value of left operand is less than the value of right
operand, if yes then condition becomes true.
|
(a < b) is true
|
>=
|
Checks if the value of left operand is greater than or equal to the
value of right operand, if yes then condition becomes true.
|
(a >= b) is not true.
|
<=
|
Checks if the value of left operand is
less than or equal to the value of right operand, if yes then condition
becomes true.
|
(a <= b) is true.
|
!<
|
Checks if the value of left operand is not less than the value of
right operand, if yes then condition becomes true.
|
(a !< b) is false.
|
!>
|
Checks if the value of left operand is not greater than the value of
right operand, if yes then condition becomes true.
|
(a !> b) is true.
|
3)
Relational Operators:
Operator
|
Description
|
Example
|
AND
|
Called Logical AND
operator. If both the conditions are True then Expression becomes true.
|
a<>0 AND
b<>0 is False.
|
OR
|
Called Logical OR
Operator. If any of the two conditions are True then condition becomes true.
|
a<>0 OR
b<>0 is true.
|
NOT
|
Called Logical NOT
Operator. Use to reverses the logical state of its operand. If a condition is
true then Logical NOT operator will make false.
|
NOT(a<>0 OR
b<>0) is false.
|
XOR
|
Called Logical
Exclusion. It is the combination of NOT and OR Operator. If one, and only
one, of the expressions evaluates to True, result is True.
|
(a<>0 XOR
b<>0) is false.
|
No comments:
Post a Comment