AppDividend
Latest Code Tutorials

# SQL Operators Example | Operators In SQL Tutorial

An operator in SQL is the reserved word or a character used primarily in the SQL statement’s WHERE clause to operate (s), such as comparisons and arithmetic operations. These reserved characters or words are known as the operators in SQL.

## SQL Operators

SQL Operators are used to specifying the conditions in the SQL statement and to serve as the conjunctions for multiple conditions in the statement. We have covered SQL Datatypes in our blog. Please check out that as well.

There are three types of Operators in SQL.

1. Arithmetic operators
2. Comparison operators
3. Logical operators

## #SQL Arithmetic Operators

SQL Arithmetic operators are used to perform mathematical calculations like addition, subtraction, multiplication, division, and modulus in SQL statements.

See the following arithmetic operators.

OperatorsDescriptionsExample
+ (Addition)The + operator is used to add containing values of both operandsx + y will give 11
– (Subtraction)The – operator subtracts right-hand operand from the left-hand operandx – y- will give -11
* (Multiplication)The * operator multiplies both operand’s valuesx * y will give 1100
/ (Division)The / operator divides left-hand operand by right-hand operandx / y will give 11
% (Modulo)The modulo operator divides left-hand operand by right-hand operand and returns reminderx % y will give 0

## #SQL Comparison Operators

Comparison operators in SQL are used to find a relation between the two columns. For example, if we want to compare the values of two columns in SQL statements.

See the following table of Comparison Operators in SQL.

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

## #SQL Logical Operators

Logical operators in the SQL are used to perform the logical operations on the given expressions in SQL. There are many operators in the SQL which are used in the SQL statements in the WHERE clause.

See the following Logical Operator in SQL.

OperatorsDescriptions
ALLThe + operator is used to add the containing values of both the operands.
ANDThe – operator subtracts a right-hand operand from the left-hand operand.
ANYThe * operator multiplies both of the operand’s values.
BETWEENThe / operator divides the left-hand operand by right-hand operand.
INThe modulo operator divides a left-hand operand by right-hand operand and returns reminder.
NOTThe NOT operator reverses a meaning of the logical operator with which it is used. E.g., NOT EXISTS, NOT BETWEEN, NOT IN, etc. This is the negate an operator.
ORThe OR operator is used to combine the multiple conditions in an SQL statement’s WHERE clause.
EXISTSThe EXISTS operator is used to search for a presence of the row in the specified table that meets specific criteria.
LIKEThe LIKE operator is used to compare the value to similar values using wildcard operators.

Finally, SQL Operators Tutorial With Example From Scratch is over.