SQL Operators

19 August 2025

An SQL operator is a reserved word or character used in SQL statements to perform various operations, such as comparisons and arithmetic calculations. These operators are essential for manipulating and filtering data in a relational database. SQL operators can be categorized into different types:

  1. Arithmetic Operators:
    • + (Addition): Adds two numbers.
      • Example: 10 + 20 returns 30
    • - (Subtraction): Subtracts the right operand from the left operand.
      • Example: 20 - 30 returns -10
    • * (Multiplication): Multiplies two numbers.
      • Example: 10 * 20 returns 200
    • / (Division): Divides the left operand by the right operand.
      • Example: 20 / 10 returns 2
    • % (Modulus): Returns the remainder of the division.
      • Example: 5 % 2 returns 1
  2. Comparison Operators:
    • = (Equal to): Checks if two values are equal.
      • Example: 5 = 5 returns TRUE
    • != or <> (Not equal to): Checks if two values are not equal.
      • Example: 5 != 6 returns TRUE
    • > (Greater than): Checks if the left operand is greater than the right operand.
      • Example: 4 > 5 returns FALSE
    • < (Less than): Checks if the left operand is less than the right operand.
      • Example: 4 < 5 returns TRUE
    • >= (Greater than or equal to): Checks if the left operand is greater than or equal to the right operand.
      • Example: 4 >= 5 returns FALSE
    • <= (Less than or equal to): Checks if the left operand is less than or equal to the right operand.
      • Example: 4 <= 5 returns TRUE
  3. Logical Operators:
    • AND: Logical AND, returns TRUE if both conditions are TRUE.
    • OR: Logical OR, returns TRUE if at least one condition is TRUE.
    • NOT: Logical NOT, reverses the value of the Boolean expression.
    • IN: Checks if a value matches any value in a list or a subquery.
    • BETWEEN: Checks if a value is within a specified range.
    • LIKE: Compares a value to a pattern using wildcard characters.
  4. Operators used to Negate Conditions:
    • IS NULL: Checks if a value is NULL.
    • IS NOT NULL: Checks if a value is not NULL.
  5. Other Operators:
    • ALL: TRUE if all of a set of comparisons are TRUE.
    • ANY or SOME: TRUE if any one of a set of comparisons are TRUE.
    • UNIQUE: Searches for uniqueness (no duplicates).
    • EXISTS: TRUE if the subquery returns one or more records.
Operator Precedence: The order in which SQL evaluates operators is determined by their precedence. Operators with higher precedence are evaluated first. For example, multiplication has higher precedence than addition.Example:SELECT 20 - 3 * 5;
This will result in 5 because multiplication is evaluated first, and then subtraction occurs.


Sajan Tonge 
Founder & CEO 

My Analytics School