w3resource

SQL Operators

What are SQL operators?

An operator performs on separate data items and returns a result. The data items are called operands or arguments. Operators are mentioned by special characters or by keywords. For example , the plus operator is represented by a plus (+) sign and the operator that checks for nulls are represented by the keywords IS NULL or IS NOT NULL.

Types of SQL operators

SQL operators Description
SQL Arithmetic Operator Arithmetic operators can perform arithmetical operations on numeric operands involved. Arithmetic operators are addition(+), subtraction(-), multiplication(*) and division(/). The + and - operators can also be used in date arithmetic.
SQL Comparison Operator A comparison (or relational) operator is a mathematical symbol which is used to compare two values. The result of a comparison can be TRUE, FALSE, or UNKNOWN.
SQL Assignment operator In SQL the assignment operator ( = ) assigns a value to a variable or of a column or field of a table. In all of the database platforms the assignment operator used like this and the keyword AS may be used as an operator for assigning table or column-heading aliases.
SQL Bitwise Operator The Bitwise operators perform bit manipulations between two integer expressions of the integer data type category. The bitwise operators are & ( Bitwise AND ), | ( Bitwise OR ) and ^ ( Bitwise Exclusive OR or XOR ). The valid datatypes for bitwise operators are BINARY, BIT, INT, SMALLINT, TINYINT, and VARBINARY.
SQL Logical Operator The Logical operators are those that are true or false. They return a true or false values to combine one or more true or false values. The logical operators are AND , OR, NOT, IN, BETWEEN, ANY, ALL, SOME, EXISTS and LIKE. The IN operator checks a value within a set of values separated by commas and retrieve the rows from the table which are matching. The IN returns 1 when the search value presents within the range otherwise returns 0. The BETWEEN operator tests an expression against a range. The range consists of a beginning, followed by an AND keyword and an end expression. The operator returns 1 when the search value present within the range otherwise returns 0. The ANY, ALL, and SOME specifiers can be used as comparison operator to compare for advanced queries. The ANY and SOME compare a value to each value in a list or results from a query. It returns no rows when the operators evaluate to false.
SQL Unary Operator The SQL Unary operators perform such an operation which contain only one expression of any of the datatypes in the numeric datatype category. Unary operators may be used on any numeric datatype, though the bitwise operator (~) may be used only on integer datatypes. The Unary operator ( + ) means the numeric value is positive, the ( - ) means the numeric value is negative, the ( ~ ) means a bitwise NOT; returns the complement of the number ( except in Oracle )

Check out our 1000+ SQL Exercises with solution and explanation to improve your skills.

Previous: Where Clause
Next: Arithmetic Operator



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/sql/operators.php