SQL Operators
SQL operators are used to perform operations on data in SQL statements. These are mainly categorized into:
- Arithmetic Operators
- Comparison Operators
- Logical Operators
SQL Arithmetic Operators
| Operator | Description |
|---|---|
+ | Adds values of both operands. |
- | Subtracts the right-hand operand from the left-hand operand. |
* | Multiplies values of both operands. |
/ | Divides the left-hand operand by the right-hand operand. |
% | Returns the remainder of the division between two operands. |
SQL Comparison Operators
| Operator | Description |
|---|---|
= | Checks if the values of two operands are equal. |
!= | Checks if the values of two operands are not equal. |
<> | Same as !=, checks for inequality. |
> | Checks if the left operand is greater than the right operand. |
< | Checks if the left operand is less than the right operand. |
>= | Checks if the left operand is greater than or equal to the right operand. |
<= | Checks if the left operand is less than or equal to the right operand. |
!> | Checks if the left operand is not greater than the right operand. |
!< | Checks if the left operand is not less than the right operand. |
SQL Logical Operators
| Operator | Description |
|---|---|
AND | Returns true if both conditions are true. |
OR | Returns true if any one condition is true. |
NOT | Reverses the result of the condition (i.e., true becomes false, and vice versa). |