公司项目里有个地方搜字段为空时写的是 is not null , 这是个varchar,于是查出来有些可能是空格的值。
1、不为空
Select * From table Where id<>''
Select * From table Where id!=''
2、为空
Select * From table Where id=''
Select * From table Where ISNULL(id)
具体情况具体分析,如果字段是char和varchar型用 id=''可以;如果是int型用 ISNULL好些
转载于:https://my.oschina.net/u/3677090/blog/1829640
最后
以上就是跳跃滑板最近收集整理的关于mysql查询字段为空时需要注意的地方的全部内容,更多相关mysql查询字段为空时需要注意内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复