# SQL Operators: The Complete Guide

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 specify 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.

- Arithmetic operators
- Comparison operators
- Logical operators

**SQL Arithmetic Operators**

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

See the following arithmetic operators.

Operators | Descriptions | Example |
---|---|---|

+ (Addition) | The + operator is used to add containing values of both operands | x + y will give 11 |

– (Subtraction) | The – operator subtracts the right-hand operand from the left-hand operand | x – y- will give -11 |

* (Multiplication) | The * operator multiplies both operand’s values | x * y will give 1100 |

/ (Division) | The / operator divides left-hand operand by right-hand operand | x / y will give 11 |

% (Modulo) | The modulo operator divides the left-hand operand by the right-hand operand and returns the remainder. | x % 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.

Operator | Description | Example |
---|---|---|

= | 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 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 the condition becomes true. | (a <> b) is true. |

> | The > operator checks if the value of the left operand is greater than the 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 right operand, if yes, 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, the 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, the condition becomes true. | (a !> b) is true. |

**#SQL Logical Operators**

Logical operators in SQL 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.

Operators | Descriptions |
---|---|

ALL | The + operator is used to add the containing values of both the operands. |

AND | The – operator subtracts a right-hand operand from the left-hand operand. |

ANY | The * operator multiplies both of the operand’s values. |

BETWEEN | The / operator divides the left-hand operand by the right-hand operand. |

IN | The modulo operator divides a left-hand operand by a right-hand operand and returns a reminder. |

NOT | The NOT operator reverses the 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. |

OR | The OR operator combines the multiple conditions in an SQL statement’s WHERE clause. |

EXISTS | The EXISTS operator is used to search for the presence of the row in the specified table that meets specific criteria. |

LIKE | The LIKE operator compares the value to similar values using wildcard operators. |

That’s it for this tutorial.