Is there a reason not to use <=> (null safe equals operator) in mysql instead of =?

后端 未结 5 2284
自闭症患者
自闭症患者 2021-02-13 16:47

MySQL provides a nice operator <=> that works with comparisons that could contain a null such as null <=> null or null <=> 5

5条回答
  •  面向向阳花
    2021-02-13 17:09

    Is there a reason MySql has both and not JUST the functionality in <=> ? The operators are completely different from each other.

    <=> 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.

    Who really needs an operator that is effectively undefined with built in language types?

    This depends on case, just because you haven't encountered such cases, does not mean nobody needs it.

提交回复
热议问题