MySQL Tutorial/Comparison Functions Operators/NULL safe equal

Материал из SQL эксперт
Перейти к: навигация, поиск

NULL-safe equal :<=>

NULL-safe equal(<=>) performs an equality comparison like the = operator.

NULL-safe equal(<=>) returns 1 rather than NULL if both operands are NULL.

NULL-safe equal(<=>) returns 0 rather than NULL if one operand is NULL.



   <source lang="sql">

mysql> mysql> SELECT 1 <=> 1, NULL <=> NULL, 1 <=> NULL; +---------+---------------+------------+ | 1 <=> 1 | NULL <=> NULL | 1 <=> NULL | +---------+---------------+------------+ | 1 | 1 | 0 | +---------+---------------+------------+ 1 row in set (0.00 sec) mysql> mysql> SELECT 1 = 1, NULL = NULL, 1 = NULL; +-------+-------------+----------+ | 1 = 1 | NULL = NULL | 1 = NULL | +-------+-------------+----------+ | 1 | NULL | NULL | +-------+-------------+----------+ 1 row in set (0.00 sec) mysql></source>