SQL Operators :
- SQL operators are reserved keywords used in the WHERE clause of a SQL statement to perform arithmetic, logical and comparison operations.
- Operators act as conjunctions in SQL statements to fulfill multiple conditions in a statement.
Type of SQL Operators :
- Arithmetic Operators
- Comparison Operators
- Logical Operators
1-Arithmetic Operators :-
The Arithmetic Operators perform the mathematical operations such as addition, subtraction and multiplication etc.
and This Operators majorly accept numeric data.
and This Operators majorly accept numeric data.
- + Addition Add values on either side of the operator
- – Subtraction Used to subtract the right hand side value from the left hand side value
- * Multiplication Multiples the values present on each side of the operator
- / Division Divides the left hand side value by the right hand side value
- % Modulus Divides the left hand side value by the right hand side value; and returns the remainder.
2- Comparison Operators:-
These operators are used to perform operations such as equal to, greater than, less than etc.
- = Equal to Used to check if the values of both operands are equal or not. If they are equal, then it returns TRUE.
- > Greater than Returns TRUE if the value of left operand is greater than the right operand.
- < Less than Checks whether the value of left operand is less than the right operand, if yes returns TRUE.
- >= Greater than or equal to Used to check if the left operand is greater than or equal to the right operand, and returns TRUE, if the condition is true.
- <= Less than or equal to Returns TRUE if the left operand is less than or equal to the right operand.
- <> or != Not equal to Used to check if values of operands are equal or not. If they are not equal then, it returns TRUE.
- !> Not greater than Checks whether the left operand is not greater than the right operand, if yes then returns TRUE.
- !< Not less than Returns TRUE, if the left operand is not less than the right operand.
3-Logical Operators :-
The Logical Operators in SQL perform the Boolean operations, which give two results True and False. These operators provide True value if both operands match the logical condition.
ANY Compares a specific value to any of the values present in a set.
IN Used to compare a specific value to the literal values mentioned.
BETWEEN Searches for values within the range mentioned.
AND Allows the user to mention multiple conditions in a WHERE clause.
OR Combines multiple conditions in a WHERE clause.
NOT A negate operators, used to reverse the output of the logical operator.
EXISTS Used to search for the row’s presence in the table.
LIKE Compares a pattern using wildcard operators.
SOME Similar to the ANY operator, and is used compares a specific value to some of the values present in a set.ults True and False. These operators provide True value if both operands match the logical condition