MySQL<=>是什么鬼

官网描述

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

数据库三值逻辑

原文地址:https://www.cnblogs.com/klarck/p/13420087.html