MySQL 判空相等运算符是什么?它与比较运算符有何不同?
MySQL NULL-safe 相等运算符相当于标准 SQL IS NOT DISTINCT FRON 运算符,执行类似于 = 运算符的相等性比较。符号为 <=>。当操作数均为 NULL 时,它与比较运算符执行的方式不同。考虑以下示例来理解 NULL 安全运算符及其与比较运算符之间的差异 -
mysql> Select 50 <=> 50, NULL <=> NULL, 100 <=> NULL; +-----------+---------------+--------------+ | 50 <=> 50 | NULL <=> NULL | 100 <=> NULL | +-----------+---------------+--------------+ | 1 | 1 | 0 | +-----------+---------------+--------------+ 1 row in set (0.00 sec) mysql> Select 50 = 50, NULL = NULL, 100 = NULL; +---------+-------------+------------+ | 50 = 50 | NULL = NULL | 100 = NULL | +---------+-------------+------------+ | 1 | NULL | NULL | +---------+-------------+------------+ 1 row in set (0.00 sec)
广告