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 operator
- Comparison operator
- Logical operator
We can use various arithmetic operators on the data stored in the tables. Arithmetic Operators are:
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.
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:
|>=||Greater than equal to.|
|<=||Less than equal to.|
|<>||Not equal to.|
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.
ALL is used to select all records of a SELECT STATEMENT. It compares a value to every value in a list of 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’.
|SOME||SOME 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.|
|UNIQUE||UNIQUE operator searches every unique row of a specified table.|
Please Login to comment...