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:

Operator Description Example
+ Addition – Adds values on either side of the operator a + b will give 300
Subtraction – Subtracts right hand operand from left hand operand a – b will give -100
* Multiplication – Multiplies values on either side of the operator a * b will give 2000
/ Division – Divides left hand operand by right hand operand b / a will give 20
% Modulus – Divides left hand operand by right hand operand and returns remainder b % 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:

Operator Description Example
= 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:

Operator Description
ALL The ALL operator is used to compare a value to all values in another value set.
AND The AND operator allows the existence of multiple conditions in an SQL statement’s WHERE clause.
ANY The ANY operator is used to compare a value to any applicable value in the list according to the condition.
BETWEEN The BETWEEN operator is used to search for values that are within a set of values, given the minimum value and the maximum value.
EXISTS The EXISTS operator is used to search for the presence of a row in a specified table that meets certain criteria.
IN The IN operator is used to compare a value to a list of literal values that have been specified.
LIKE The LIKE operator is used to compare a value to similar values using wildcard operators.
NOT The 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.
OR The OR operator is used to combine multiple conditions in an SQL statement’s WHERE clause.
IS NULL The NULL operator is used to compare a value with a NULL value.
UNIQUE The 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:

Operator Description
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 Statement Description

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

# 120+ Professional Project Management Templates!

A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.

LIMITED TIME OFFER
ON SALE80% OFF

Excel Templates

120+ Project Management Templates Pack

Excel | PowerPoint | Word

ULTIMATE RESOURCE MANAGEMENT TEMPLATE

Excel Template

50+ Essential Project Management Templates

Excel | PowerPoint | Word

Project Portfolio Management Templates

Excel | PowerPoint Templates

50+ Excel Project Management Templates

Excel Templates

By Published On: January 13th, 2013Categories: SQLTags: