MySQL Tutorial
Operators are used to perform operations on variables and values.
MySQL statements generally contain some reserved words or characters that are used to perform operations
MySQL Operators are used to specify conditions in an MySQL statement and to serve as conjunctions for multiple conditions in a statement
there are three types of operators in MySQL:
Assume 'variable a' value is 30 and 'variable b' value is 60, then
Operators | Descriptions | Examples |
---|---|---|
+ | Adds values | a+b will give 90 |
- | Subtracts right hand from left hand . | a-b will give -30 |
* | Multiplies values | a*b will give 1800 |
/ | Divides left hand by right hand . | b/a will give 2 |
% | Divides left hand by right hand and returns remainder. | b%a will give 0 |
Assume 'variable a' value is 30 and 'variable b' value is 60, then
Operator | Description | Example |
---|---|---|
= | Checks if the both operands value that are equal or not,if yes condition become true. | (a=b) is not true |
!= | This is used to check the value of both operands equal or not,if not condition become true. | (a!=b) is true |
<> | Checks if the operand's value equal or not, if values are not equal condition is true | (a <>b) is true |
> | Checks if the the left operand value is greater than right Operand, if yes condition becomes true | (a>b) is not true |
< | Checks if the left operand value is less than right Operand, if yes condition becomes true | (a |
>= | Checks if the value of left operand is greater than or equal to the value of right operand or not,if yes condition become true | (a>=b) is not true |
<= | Checks if the value of left operand is less than or equal to the value of right operand or not, if yes condition becomes true | (a <=b) is true |
! < | Checks if the left operand value is not less than the right operand value | (a! |
!> | Checks if the value of left operand is not greater than the value of right operand | (a!>b) is true |
Here is a list of all the logical operators available in MySQL.
Operator | Description |
---|---|
ALL | ALL operator is used to compare a value to all values in another value set. |
AND | AND operator allows the existence of multiple conditions in an MySQL statement. |
ANY | ANY operator is used to compare the value in list according to the condition. |
BETWEEN | BETWEEN operator is used to search for values, that are within a set of values |
IN | IN operator is used to compare a value to that specified list value |
NOT | NOT operator reverse the meaning of any logical operator |
OR | OR operator is used to combine multiple conditions in MySQL statements |
EXISTS | EXISTS operator is used to search for the presence of a row in a specified table |
LIKE | LIKE operator is used to compare a value to similar values using wildcard operator |