SQL - Operators


Previous Page Next Page

Operators are used to perform operation on two operands. Operators in SQL can be categorized as follows:

  • Arithmetic operators
  • Comparison operators
  • Logical operators

Arithmetic operators

Arithmetic operators are used to perform arithmetic operations on two operands.

+ Addition
- Subtraction
* Multiplication
/ Division
% Modulusa%b returns remainder of a/b (ex: 10 % 3 returns 1)

Comparison operators

Comparison operators are used to compare values of two operands. It returns true when values matches and false when values does not match.

Operator Description
= Equal
!= Not equal
<> Not equal
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
!> Not Greater than
!< Not Less than

Logical operators

Logical operators are used to create and combine one or more conditions.

Operator Description
ALL Returns true if all of the subquery values meet the condition
AND Only includes rows where both conditions is true
ANY Returns true if any of the subquery values meet the condition
BETWEEN Selects values within a given range
EXISTS Tests for the existence of any record in a subquery
IN Allows you to specify multiple values in a WHERE clause
LIKE Searches for a specified pattern in a column
NOT Only includes rows where a condition is not true
OR Returns True when any of the conditions is true
IS NULL Tests for empty values
UNIQUE A constraint that ensures that all values in a column are unique

Previous Page Next Page