adplus-dvertising

SQL Operators

last news

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

1. Arithmetic operators

Operator Description
+ (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.

2. Comparison operators

Operator Description
= 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.

3. Logical operators

Operator Description
ALL The ALL operator allows you to compare a value to all the values in another set of values.
AND The AND operator allow to combine two or more condition, it returns true if all conditions are true.
OR The OR operator allow to combine two or more condition, it returns true if at least one of the conditions is true.
ANY The operator ANY is used to compare a value to an applicable value in the list according to the condition.
BETWEEN The BETWEEN operator makes it possible to search for values included in a set of values, according to the minimum value and the maximum value.
EXISTS The EXISTS operator is used to find the presence of a row in a specified table that meets a certain criterion.
IN The operator IN is used to compare a value to a list of specified literal values.
LIKE The LIKE operator is used to compare a value to similar values using generic operators.
NOT The 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 NULL The IS NULL operator is used to compare a value with a NULL value.
UNIQUE The UNIQUE operator searches each row in the specified table for uniqueness (no duplicates).
Partager ce cours avec tes amis :
Rédigé par ESSADDOUKI Mostafa
ESSADDOUKI
The education of the 21st century opens up opportunities to not merely teach, but to coach, mentor, nurture and inspire.