SQL Operators
Operators are used to do comparisions, arithimetic operations etc. The different types of OPERATORS we use on day to day basis are:
1.Arithmetic operators
2.Comparison operators
3.Logical operators
4.Bitwise Operators
Arithmetic Operators
Comparison operators
Logical operators
Bitwise Operators
1.Arithmetic operators
| Operator | Name | Decsription |
|---|---|---|
| + | Addition | Adds or Concatenates the variables. |
| - | Subtraction | Subtracts the right hand variable from the left hand variable. |
| * | Multiplication | Multiplies the variables. |
| / | Divison | Divides the left hand variable by the right hand variable. |
| % | Modulus | Divides the left hand variable by the right hand variable and returns remainder. |
2.Comparison operators
| Operator | Name | Decsription |
|---|---|---|
| = | Equal to | Checks if the values of two operands are equal or not, if yes then condition becomes true. |
| != | Not equal to | Checks if the values of two operands are equal or not, if values are not equal then condition becomes true. |
| <> | Not equal to | Checks if the values of two operands are equal or not, if values are not equal then condition becomes true. |
| > | Greater than | Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. |
| < | Less than | Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true. |
| >= | Greater than or equal | Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. |
| <= | Less than or Equal | Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true. |
| !< | Not less than | Checks if the value of left operand is not less than the value of right operand, if yes then condition becomes true. |
| !> | Not less than | Checks if the value of left operand is not greater than the value of right operand, if yes then condition becomes true.. |
3.Logical operators
| Operator | Decsription |
|---|---|
| ALL | Checks if all of the subquery values meet the condition. |
| SOME | Checks if any of the subquery values meet the condition. |
| OR | Displays a record if the condition(s) is NOT TRUE |
| LIKE | Checks if the operand matches a pattern. |
| IN | Checks if the operand is equal to one of a list of expressions. |
| EXISTS | Checks if the subquery returns one or more records. |
| BETWEEN | Checks if the operand is within the range of comparisons. |
| ANY | Checks f any of the subquery values meet the condition. |
| AND | Checks i if all the conditions separated by AND is TRUE. |
4. Bitwise Operators
| Operator | Decsription |
|---|---|
| & | Bitwise AND. |
| | | Bitwise OR. |
| ^ | Bitwise exclusive OR. |