Home >Database >Mysql Tutorial >What does '=' in mysql mean?
In mysql, "=" means equality. It is a comparison operator. It is mainly used to compare whether the operands on both sides are equal. If they are equal, it returns 1. If they are not equal, it returns 0. Note that "=" cannot be used to judge the null value NULL, so if one or two operands are NULL, the result of the comparison operation is NULL.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
In mysql, "=
" means equality and is a comparison operator.
=
The operator is used to compare whether the operands on both sides are equal. If they are equal, it returns 1; if they are not equal, it returns 0. The specific syntax rules are as follows:
If one or two operands are NULL, the result of the comparison operation is NULL. (Reason: NULL cannot be used for = comparison.)
If both operands are strings, compare them as strings.
If both operands are integers, the comparison is based on integers.
If one operand is a string and the other operand is a number, MySQL can automatically convert the string to a number.
Example: Use = for equality judgment
mysql> SELECT 1=0,'2'=2,2=2,'0.02'=0,'b'='b',(1+3)=(2+2),NULL=null; +-----+-------+-----+----------+---------+-------------+-----------+ | 1=0 | '2'=2 | 2=2 | '0.02'=0 | 'b'='b' | (1+3)=(2+2) | NULL=null | +-----+-------+-----+----------+---------+-------------+-----------+ | 0 | 1 | 1 | 0 | 1 | 1 | NULL | +-----+-------+-----+----------+---------+-------------+-----------+ 1 row in set (0.01 sec)
Analysis of running results:
##2=2 The return values of and
'2' =2 are the same, both are 1, because MySQL automatically converts the character '2' into the number 2 when making the judgment.
'b'='b' is the same character comparison, so the return value is 1.
1 3 and expression
2 2 are both
4, so the results are equal, return The value is 1;
= cannot be used to judge the null value
NULL, therefore
NULL=null The return value is
NULL.
mysql video tutorial]
The above is the detailed content of What does '=' in mysql mean?. For more information, please follow other related articles on the PHP Chinese website!