An operator is a word or character reserved primarily for operations like comparisons and arithmetic operations, used in the WHERE clause of a SQL query. These operators are used in a SQL statement to declare conditions and provide numerous situations in a query.
Suppose that variable an is 10 and that variable b is 20 then –
Operator | Description | Example |
---|---|---|
+ (Addition) | Adds values on either side of the operator. | a + b will give 30 |
- (Subtraction) | Right hand operand of the left hand operand is subtracted. | a - b will give -10 |
* (Multiplication) | Multiplies the operator's values on either side. | a * b will give 200 |
/ (Division) | The left hand is divided by the right hand hand operand. | b / a will give 2 |
% (Modulus) | Divide the left hand operand and return the rest. | b % a will give 0 |
Suppose that variable an is 10 and that variable b is 20 then –
Operator | Description | Example |
---|---|---|
= | Checks whether the values of two transactions are equivalent or not. | (a = b) is not true. |
!= | Checks whether the values of both operands are the same or not, and whether the values are not the same, the condition becomes true. | (a != b) is true. |
<> | Checks whether the values of both operands are the same or not, and whether the values are not the same, the condition becomes true. | (a <> b) is true. |
> | If yes then the condition is true, verify if the value of the left operand is greater than the value of the right operand. | (a > b) is not true. |
< | If yes, then it is true if the value of the left operand is lower than that of the right operand. | (a < b) is true. |
>= | Checks if the left-operand value is greater or equal to the right-operand value, if the condition is true. | (a >= b) is not true. |
<= | Checks if the left operand value is smaller or equal to the right operand value, if yes then the condition is true. | (a <= b) is true. |
!< | Checks if the left operand value is no smaller than the right operand value, if yes, then the condition is true. | (a !< b) is false. |
!> | Checks if the left operand value does not exceed the right operand value, if yes the condition then becomes true. | (a !> b) is true. |
This is a list of all SQL logical operators.
Sr.No | Operator & Description |
---|---|
1 | ALL The ALL operator compares a value to all values in a different set of values. |
2 | AND The AND operator permits multiple conditions to exist in the WHERE clause of a SQL query. |
3 | ANY The ANY operator is used to compare a value with any value in the list, depending on the criterion. |
4 | BETWEEN In the case of a minimum value and the maximum value, the BETWEEN operator can search for values inside a set of values. |
5 | EXISTS EXISTS A ROWER in a given table that meets a certain requirement is used to search for the existence of a row. |
6 | IN The IN operator compares a value with a list of the provided literal values. |
7 | LIKE The LIKE operator uses wildcard operators to compare the same value with comparable values. |
8 | NOT The NOT operator reverses the significance of the logical user it is used with. For example: NOT ARE, NOT ARE, etc. This is an operator that is negative. |
9 | OR The OR operator can be used in a WHERE SQL statement to combine multiple conditions. |
10 | IS NULL Using NULL, a value is compared with a value of NULL. |
11 | UNIQUE Each row of the table supplied is searched by the UNIQUE operator (no duplicates). |
|