What is an Operator in SQL?
An operator may be a reserved word or a character used primarily in AN SQL statement’s wherever clause to perform an operation(s), equivalent to comparisons and arithmetic operations.
- Arithmetic operators
- Comparison operators
- Logical operators
- Operators used to negate conditions
A. Arithmetic operators
- + (Addition) – This SQL operator adds values on either side of the operator
- – (Subtraction) – This SQL operator subtracts right-hand operand from left-hand operand.
- * (Multiplication) – This SQL operator multiplies values on either side of the operator.
- / (Division) – This SQL operator divides mitt operand by right-hand operand.
- % (Modulus) – This operator divides the left-hand operand by the right-hand operand and returns the remainder.
B. Comparison operators
- = – This SQL operator checks if the values of 2 operands area unit equal or not, if yes then condition becomes true.
- != – This SQL operator checks if the values of 2 operands area unit equal or not if values aren’t equal then condition becomes true.
- <> – This operator checks if the values of 2 operands area unit equal or not, if values aren’t equal then condition becomes true.
- > – This operator checks if the value of the left quantity is larger than the worth of right quantity, if yes then condition becomes true.
- < – This operator checks if the worth of the left operand is a smaller amount than the value of right quantity, if yes then condition becomes true.
- >= – This operator checks if the worth of left operand is larger than or up to the worth of right operand, if yes then condition becomes true.
- <= – This operator checks if the worth of left operand is less than or up to the value of right operand, if yes then condition becomes true.
- !< – This operator checks if the value of left operand isn’t below the value of right operand, if yes then condition becomes true.
- !> – This operator checks if the value of left operand isn’t larger than the value of right operand, if yes then condition becomes true.
C. Logical operators:
- ALL – The ALL operator employes to match to any or all values in another value set.
- AND – The AND operator permits the existence of multiple conditions in an SQL statement’s wherever clause.
- ANY – The ANY operator uses to match to any applicable value within the list as per the condition.
- BETWEEN – The BETWEEN operator uses to search for values that area unit within a set of values, given the minimum price and therefore the maximum value.
- EXISTS – The EXISTS operator uses to go looking for the presence of a row in an exceedingly specified table that meets a particular criterion.
- IN – The IN operator uses to match a value to a list of literal values that are such.
- LIKE – The LIKE operator uses to match a value to similar values using wildcard operators.
- NOT – The NOT operator reverses the means of the logical operator with that we use it. E.g.: NOT EXISTS, NOT BETWEEN, NOT IN, etc. this is often a negate operator.
- OR – The OR operator uses to mix multiple conditions in an SQL statement’s wherever clause.
- IS NULL – The NULL operator uses to match a with a NULL value.
- UNIQUE – The unique operator searches each row of a table for uniqueness (no duplicates).
So, this was all in SQL Operators. Hope you like our explanation.
Note: In this SQL Operators tutorial, we discussed 3 main operators in SQL. These SQL Operators are arithmetic, comparison, and logical operators. Still, if any query regarding SQL Operators, ask in the comment tab.