# SQL Operators Tutorial With Example From Scratch

SQL Operators Tutorial With Example From Scratch is today’s topic. SQL operator 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. These 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.

**SQL Operators**

Content Overview

There are three types of Operators in SQL.

- Arithmetic operators
- Comparison operators
- 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.

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

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

– (Subtraction) | The – operator subtracts 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 left-hand operand by right-hand operand and returns reminder | 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 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.

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 right-hand operand. |

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

NOT | The 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. |

OR | The OR operator is used to combine the multiple conditions in an SQL statement’s WHERE clause. |

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

LIKE | The LIKE operator is used to compare the value to similar values using wildcard operators. |

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