MySQL (Part 5) and mysql (Part 5)
Common operators 1. Arithmetic Operators
Operator |
Function |
+ |
Addition operation |
- |
Subtraction |
* |
Multiplication |
/ |
Division |
% |
Remainder operation |
2. Comparison Operators
Operator |
Function |
= |
Equal |
<=> |
Security equals. Can be used to determine NULL |
<>! = |
Not equal |
<= |
Less than or equal |
> = |
Greater than or equal |
IS NULL |
Empty or not |
IS NOT NULL |
Not empty |
LEAST |
Returns the minimum value. |
GRETEST |
Maximum Value |
BETWEEN AND |
Between two values |
ISNULL |
Equivalent to IS NULL |
IN |
Determines whether a value is any value IN the IN column. |
NOT IN |
Judge that a value is not any value IN the IN column. |
LIKE |
Wildcard match |
REGEXP |
Regular Expression |
3. logical operators
Operator |
Function |
AND or && |
Logic and |
NOT or! |
Non-logical |
OR | |
Logic or |
XOR |
Logic exclusive or |
NOT or!
It indicates that when the operand is 0, the obtained value is 1. When the operand is not 0, the obtained value is 0. When the operand is NULL, the returned value is NULL.
AND or &&
Logic AND operator AND or & indicates that when all operands are non-zero values AND not NULL, the calculation result is 1. When one or more operands are 0, the result is 0, and the return value is NULL in other cases.
OR |
Logical OR operator OR | indicates that if both operands are non-NULL values and any operand is non-zero, 1 is returned; otherwise, 0 is returned; when one operand is NULL and the other operand is non-zero, the result is 1; otherwise, the result is NULL. When both operands are NULL, the result is NULL.
XOR
Logical XOR operator (XOR. If any operand is NULL, NULL is returned. For non-NULL operands, if both operands are non-0 or both are 0 values, 0 is returned. If a value is 0, if the other value is non-zero, 1 is returned.