官网描述
NULL
-safe equal. This operator performs an equality comparison like the = operator, but returns 1
rather than NULL
if both operands are NULL
, and 0
rather than NULL
if one operand is NULL
.
NULL
-安全相等。此运算符执行类似于相等比较 =运算符,差别是:
如果两个操作数都是
NULL则返回1
,而不是
NULL
,
如果只一个操作数是
则返回NULL
0,而
不是NULL
。
mysql> SELECT 1 <=> 1, NULL <=> NULL, 1 <=> NULL;
-> 1, 1, 0
mysql> SELECT 1 = 1, NULL = NULL, 1 = NULL;
-> 1, NULL, NULL