SQL Operators

SQL Operators

An operator is a reserved word or character used primarily in the WHERE clause of an SQL statement to perform operations, such as comparisons and arithmetic operations. These operators are used to specify conditions in an SQL statement and to serve as conjunctions for multiple conditions in a statement.

  •  Arithmetic operators
  •  Comparison operators
  •  Logical operators

Arithmetic operators

OperatorDescription
+ (Addition)Add values on each side of the operator.
- (Substraction)Subtracts the right operand from the left operand.
* (Multiplication)Multiplies the values on each side of the operator.
/ (Division)Divides the left operand by the right operand.
% (Rest of division or modulo)Divide the left operand by the right operand and return the rest.

Comparison operators

OperatorDescription
=Check if the values of two operands are equal or not, if so, the condition becomes true.
!=Check if the values of two operands are equal or not, if the values are not equal, then the condition becomes true.
<>Check if the values of two operands are equal or not, if the values are not equal, then the condition becomes true.
>Checks if the value of the left operand is greater than the value of the right operand. If so, the condition becomes true.
<Checks if the value of the left operand is less than the value of the right operand. If so, the condition becomes true.
>=Checks if the value of the left operand is greater than or equal to the value of the right operand, if so, the condition becomes true.
<=Checks if the value of the left operand is less than or equal to the value of the right operand. If so, the condition becomes true.
!<Checks if the value of the left operand is not less than the value of the right operand. If the answer is yes, the condition becomes true.
!>Check if the value of the left operand is not greater than the value of the right operand, if so, the condition becomes true.

Logical operators

OperatorDescription
ALLThe ALL operator allows you to compare a value to all the values in another set of values.
ANDThe AND operator allow to combine two or more condition, it returns true if all conditions are true.
ORThe OR operator allow to combine two or more condition, it returns true if at least one of the conditions is true.
ANYThe operator ANY is used to compare a value to an applicable value in the list according to the condition.
BETWEENThe BETWEEN operator makes it possible to search for values included in a set of values, according to the minimum value and the maximum value.
EXISTSThe EXISTS operator is used to find the presence of a row in a specified table that meets a certain criterion.
INThe operator IN is used to compare a value to a list of specified literal values.
LIKEThe LIKE operator is used to compare a value to similar values using generic operators.
NOTThe NOT operator reverses the meaning of the logical operator with which it is used. Ex .: NOT EXISTS, NOT BETWEEN, NOT IN, etc. This is a negation operator.
IS NULLThe IS NULL operator is used to compare a value with a NULL value.
UNIQUEThe UNIQUE operator searches each row in the specified table for uniqueness (no duplicates).

Share this course with your friends :

This course is written by M. ESSADDOUKI Mostafa

Many people realize their hearts desires late in life. Continue learning, never stop striving and keep your curiosity sharp, and you will never become too old to appreciate life.

0 Comment(s)

To leave a comment you must have an account Sign up, or Sign in