SQL Operators – Arithmetic, Comparison, & Logical

Stay updated with the latest technology trends while you're on the move - Join DataFlair's Telegram Channel

1. Operators in SQL

In our last SQL tutorial, we discussed the RDBMS database. Today, we will see SQL Operators. Moreover, we will discuss Arithmetic, Comparison and logical operators in SQL.
So, let us start Operators in SQL.

SQL Operators

SQL Operators – Arithmetic, Comparison, & Logical

2. What are SQL Operators?

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

Have a look at RDBMS Concept

3. SQL Operators

Following are the Operators in SQL, let’ discuss the one by one:

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. SQL 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.

4. Conclusion

Hence, 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.
For reference

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.