SQL Operators

SQL Operators

Operators are reserved words or characters used primarily in an SQL statement's WHERE clause to perform operation(s), such as comparisons and arithmetic operations.

They are used to specify conditions in an SQL statement and to serve as conjunctions for multiple conditions in a statement.


1. Arithmetic Operators

These operators perform mathematical calculations.

Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo (returns the remainder of a division)

2. Comparison Operators

These operators are used to compare two values.

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

3. Logical Operators

These operators are used to combine multiple conditions.

Operator Description
ALL Returns true if all of the subquery values meet the condition
AND Returns true if all the conditions separated by AND is TRUE
ANY Returns true if any of the subquery values meet the condition
BETWEEN Returns true if an operand is within the range of comparisons
EXISTS Returns true if the subquery returns one or more records
IN Returns true if the operand is equal to one of a list of expressions
LIKE Returns true if the operand matches a pattern
NOT Reverses the meaning of the logical operator with which it is used
OR Returns true if any of the conditions separated by OR is TRUE
IS NULL The null operator

4. Bitwise Operators

Bitwise operators perform bit manipulations between two expressions of any of the data types of the integer data type category.

Operator Description
& Bitwise AND
` `
^ Bitwise exclusive OR