1.

SQL Operators

Answer»

Operators are used in SQL to form complex expressions which can be evaluated to code more intricate queries and extract more precise data from a database.

There are 3 main types of operators: Arithmetic, Comparision and Logical operators, each of which will be described below.

  • Arithmetic Operators:

Arithmetic Operators allows the user to perform arithmetic operations in SQL. The table below shows the list of arithmetic operators available in SQL:

OperatorDescription
+Addition
-Subtraction
*Multiplication
/Division
%Modulo
  • Bitwise Operators:

Bitwise operators are used to performing Bit manipulation operations in SQL. The table below shows the list of bitwise operators available in SQL:

OperatorDescription
&Bitwise AND
|Bitwise OR
^Bitwise XOR
  • Relational Operators:

Relational operators are used to performing relational expressions in SQL, i.e those expressions whose value either result in true or false. The table below shows the list of relational operators available in SQL:

OperatorDescription
=Equal to
>Greater than
<Less than
>=Greater than or equal to
<=Less than or equal to
<>Not equal to
  • Compound Operators:

Compound operators are basically a combination of 2 or more arithmetic or relational operator, which can be used as a shorthand while writing code. The table below shows the list of compound operators available in SQL:

OperatorDescription
+=Add equals
-=Subtract equals
*=Multiply equals
/=Divide equals
%=Modulo equals
&=AND equals
|=OR equals
^=XOR equals
  • Logical Operators:

Logical operators are used to combining 2 or more relational statements into 1 compound statement whose truth value is evaluated as a whole. The table below shows the SQL logical operators with their description:

OperatorDescription
ALLReturns True if all subqueries meet the given condition.
ANDReturns True if all the conditions turn out to be true
ANYTrue if any of the subqueries meet the given condition
BETWEENTrue if the operand lies within the range of the conditions
EXISTSTrue if the subquery returns one or more records
INReturns True if the operands to at least one of the operands in a given list of expressions
LIKEReturn True if the operand and some given pattern match.
NOTDisplays some record if the set of given conditions is False
ORReturns True if any of the conditions turn out to be True
SOMEReturns True if any of the Subqueries meet the given condition.



Discussion

No Comment Found