Mysql空值(NULL)不能使用算数运算符

id type
1 null
2 1
3 2

在mysql中查询不等于‘1’的记录时,不能使用

select * from A where type<>1

这样只能查询出type为2的记录。

原因:mysql中的NULL为特殊值,算数比较时,NULL的返回结果为NULL,不是有效值


猜你喜欢

转载自blog.csdn.net/xzy53719/article/details/58589611