🖌️Operators

Arithmetic Operators

Arithmetic operators perform mathematical calculations between numeric columns or expressions.

  • + (Addition) - Adds two values together.

SELECT 10 + 5;
  • - (Subtraction) - Subtracts one value from another.

SELECT 12 - 3; 
  • * (Multiplication) - Multiplies two values.

SELECT 2 * 8;
  • / (Division) - Divides one value by another.

SELECT 10 / 5; 
  • % (Modulo) - Returns the remainder after division.

SELECT 10 % 3;

Bitwise Operators

Bitwise operators perform binary logic between numeric values at the individual bit level.

  • & (Bitwise AND) - Compares bits and returns 1 only if both bits are 1.

  • | (Bitwise OR) - Compares bits and returns 1 if either bit is 1.

  • ^ (Bitwise XOR) - Compares bits and returns 1 if the bits are different.

Comparison Operators

Comparison operators test for logical conditions between expressions.

  • = (Equal) - Checks for equality between two values.

  • > (Greater than) - Checks if left value is greater than right value.

  • < (Less than) - Checks if left value is less than right value.

  • >= (Greater than or equal to) - Checks for greater or equal condition.

  • <= (Less than or equal to) - Checks for less than or equal condition.

  • <> or != (Not equal to) - Checks for inequality between two values.

Compound Assignment Operators

Compound operators provide shorthand for performing an operation and assignment.

  • += (Add equals) - Add and assign e.g. x += 5 (x = x + 5)

  • -= (Subtract equals)

  • *= (Multiply equals)

  • /= (Divide equals)

  • %= (Modulo equals)

Logical Operators

Logical operators test for complex logical conditions involving multiple operators.

  • ALL - TRUE if all subquery values meet a condition.

  • AND - TRUE if all conditions are TRUE.

  • ANY - TRUE if any subquery values meet a condition.

  • BETWEEN - TRUE if within a range.

  • EXISTS - TRUE if subquery returns rows.

  • IN - TRUE if equal to value in list.

  • LIKE - TRUE if matches a pattern.

  • NOT - Inverts a condition's meaning.

  • OR - TRUE if any condition is TRUE.

  • SOME - TRUE if any subquery values meet a condition.

Last updated