What does <=> in MySQL mean and do?
解决方案
The manual says it all:
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.
mysql> select NULL <=> NULL;
+---------------+
| NULL <=> NULL |
+---------------+
| 1 |
+---------------+
1 row in set (0.00 sec)
mysql> select NULL = NULL;
+-------------+
| NULL = NULL |
+-------------+
| NULL |
+-------------+
1 row in set (0.00 sec)
mysql> select NULL <=> 1;
+------------+
| NULL <=> 1 |
+------------+
| 0 |
+------------+
1 row in set (0.00 sec)
mysql> select NULL = 1;
+----------+
| NULL = 1 |
+----------+
| NULL |
+----------+
1 row in set (0.00 sec)
mysql>