SQL Operators helps us to write expressions in SQL queries. We use Arithmetic Operators, Comparison Operators, Logical Operators and Wildcard Operators while extracting and summarizing the data for analysis.

## SQL Arithmetic Operators

Following are the list of all the arithmetic operators available in SQL, assume variable a holds 100 and variable b holds 200 then:

OperatorDescriptionExample
+Addition – Adds values on either side of the operatora + b will give 300
Subtraction – Subtracts right hand operand from left hand operanda – b will give -100
*Multiplication – Multiplies values on either side of the operatora * b will give 2000
/Division – Divides left hand operand by right hand operandb / a will give 20
%Modulus – Divides left hand operand by right hand operand and returns remainderb % a will give 0

## SQL Comparison Operators

Following are the list of all the comparison operators available in SQL, assume variable a holds 100 and variable b holds 200 then:

OperatorDescriptionExample
=Checks if the value of two operands are equal or not, if yes then condition becomes true.(a = b) is not true.
!=Checks if the value of two operands are equal or not, if values are not equal then condition becomes true.(a != b) is true.
<> Checks if the value of two operands are equal or not, if values are not equal then condition becomes true.(a <> b) is true.
Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.(a > b) is not true.
Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true.(a < b) is true.
>=Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.(a >= b) is not true.
<=Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.(a <= b) is true.
!<Checks if the value of left operand is not less than the value of right operand, if yes then condition becomes true.(a !< b) is false.
!>Checks if the value of left operand is not greater than the value of right operand, if yes then condition becomes true.(a !> b) is true.

## SQL Logical Operators

Following are the list of all the logical operators available in SQL:

OperatorDescription
ALLThe ALL operator is used to compare a value to all values in another value set.
ANDThe AND operator allows the existence of multiple conditions in an SQL statement’s WHERE clause.
ANYThe ANY operator is used to compare a value to any applicable value in the list according to the condition.
BETWEENThe BETWEEN operator is used to search for values that are within a set of values, given the minimum value and the maximum value.
EXISTSThe EXISTS operator is used to search for the presence of a row in a specified table that meets certain criteria.
INThe IN operator is used to compare a value to a list of literal values that have been specified.
LIKEThe LIKE operator is used to compare a value to similar values using wildcard operators.
NOTThe NOT operator reverses the meaning of the logical operator with which it is used. Eg. NOT EXISTS, NOT BETWEEN, NOT IN etc. This is negate operator.
ORThe OR operator is used to combine multiple conditions in an SQL statement’s WHERE clause.
IS NULLThe NULL operator is used to compare a value with a NULL value.
UNIQUEThe UNIQUE operator searches every row of a specified table for uniqueness (no duplicates).

## SQL Wildcard Operators

Following are the list of all the wildcard operators available in SQL, we use wildcard operators in conjunction with the LIKE operator:

OperatorDescription
The percent sign (%)Matches one or more characters. Note: MS Access uses the asterisk (*) wildcard character instead of the percent sign (%) wildcard character.
The underscore (_)Matches one character. Note: MS Access uses a question mark (?) instead of the underscore (_) to match any one character.
Character list to match (
[character list])
Sets and ranges of characters to match.
Character list not to match (^[character list])Sets and ranges of characters to match.

#### Examples:

SQL StatementDescription

Select * From Employee Where Name Like ‘M%’

Returns all the records where name starts with M

Select * From Employee Where Salary Like ‘2___0’

Returns all the records where it finds salary with a five-digit number that start with 2 and end with 0

Select * From Employee Where Department Like ‘[A-H]%’

Returns all the records where Department name start with any letter between A and H
Select * From Employee Where Department Like ‘^[A-H]%’

Returns all the records where Department name not start with any letter between A and H