Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

SQL Operators

  • Last Updated : 08 Sep, 2021

Operators are the foundation of any programming language. We can define operators as symbols that help us to perform specific mathematical and logical computations on operands. In other words, we can say that an operator operates the operands. SQL operators have three different categories.

Arithmetic operators:

We can use various arithmetic operators on the data stored in the tables. Arithmetic Operators are:

Attention reader! Don’t stop learning now. Learn SQL for interviews using SQL Course  by GeeksforGeeks.


The addition is used to perform an addition operation on the data values.


This operator is used for the subtraction of the data values.


This operator works with the ‘ALL’ keyword and it calculates division operations.


This operator is used for multiply data values.


Modulus is used to get the remainder when data is divided by another.

Comparison operators:

Another important operator in SQL is a comparison operator, which is used to compare one expression’s value to other expressions. SQL supports different types of the comparison operator, which is described below:

1=Equal to.
2>Greater than.
3<Less than.
4>=Greater than equal to.
5<=Less than equal to.
6<>Not equal to.

Logical operators:

The Logical operators are those that are true or false. They return true or false values to combine one or more true or false values.


Logical AND compares between two Booleans as expressions and returns true when both expressions are true.


Logical OR compares between two Booleans as expressions and returns true when one of the expressions is true.


Not takes a single Boolean as an argument and changes its value from false to true or from true to false.

Special operators:


ALL is used to select all records of a SELECT STATEMENT. It compares a value to every value in a list ofof results from a query. The ALL must be preceded by the comparison operators and evaluates to TRUE if the query returns no rows.


ANY compares a value to each value in a list of results from a query and evaluates to true if the result of an inner query contains at least one row.


The SQL BETWEEN operator tests an expression against a range. The range consists of a beginning, followed by an AND keyword and an end expression.


The IN operator checks a value within a set of values separated by commas and retrieves the rows from the table which are matching.


The EXISTS checks the existence of a result of a subquery. The EXISTS subquery tests whether a subquery fetches at least one row. When no data is returned then this operator returns ‘FALSE’.  

6SOMESOME operator evaluates the condition between the outer and inner tables and evaluates to true if the final result returns any one row. If not, then it evaluates to false.


My Personal Notes arrow_drop_up
Recommended Articles
Page :