# SQL – Operators

SQL Operators are reserved words , which are used to perform arithmetic, logical and comparison operation in SQL queries.

Broadly we can divide SQL operators in three parts:

- Arithmetic Operators
- Logical Operators
- Comparison Operators

##### Arithmetic Operators :

##### Used to perform arithmetic operation in SQL queries.

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

+ |
Used to add to two operands | Select 20 + 40; |

– |
Used to subtracts right hand operand from left hand operand. | Select 30 – 23; |

* |
Used to multiply both operands values. | Select 20 * 5; |

/ |
Used to divides left hand operand by right hand operand. | Select 50 / 10; |

% |
It will return the reminder value. | Select 10 % 2; |

##### Logical Operator :

** **Used to perform logical operation.

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

ALL | Used to compare a value to all the values in another set. |

AND | Used to filter data with multiple condition in where clause. |

ANY | Used to compare a value to any applicable value in the list of values. |

BETWEEN | Used to search for values among a given range of values. |

EXISTS | Used to search for the presence of a row in a specified table that meets certain criteria. |

IN | Used to compare a value to a value in list of values in a specified set. |

LIKE | Used to compare a value to similar values using wildcard operators( _ , %) . |

NOT | Reverses the meaning of the logical operator with which it is used. Eg: NOT EXISTS, NOT BETWEEN, NOT IN, etc. |

OR | Used to combine multiple conditions in an SQL statement’s WHERE clause. |

IS NULL | Used to compare a value with a NULL value. |

UNIQUE | Used to searches every row of a specified table for uniqueness. |

##### Comparison Operator :

##### Used to compare two values. Suppose values of a and b are 20 and 40 in following example.

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

= |
Used to examine if both values are equal. | (a=b) is not true |

!= |
Used to examine if both values are not equal. | (a!=b) is true |

< > |
Condition is true if values are not equal. | (a<>b) is true |

> |
Condition becomes true when a is greater than b. | (a>b) is not true |

< |
Condition becomes true when a is less than b. | (a<b) is true |

>= |
True if a is greater than or equal to b. | (a>=b) is not true |

<= |
True if a is less than or equal to b. | (a<=b) is true |

!< |
Examines that a is not less than b. | (a!<b) is not true |

!> |
Examine that a is not greater than b. | (a!>b) is true |

Nice post….