mysql null和‘ ’
2016-01-07 13:41
906 查看
null
''是空字符 相当于在银行有账号,不过没钱
null是空 相当于在银行账号都没有
null比较需要用 is null 或者 is not null 判断
null遇见运算符 一律返回null =null 或 !=null 等等一律返回null ,并且效率不高,所以建表时候一般都会有not null default '';
mysql> select goods_name from goods where goods_name is not null limit 3;
+--------------------+
| goods_name |
+--------------------+
| KD876 |
| htcN85原装充电器 |
| 诺基亚原装5800耳机 |
+--------------------+
3 rows in set (0.00 sec)
mysql> select goods_name from goods where goods_name is null ;
Empty set (0.00 sec)
null 遇见运算符 一律返回null
mysql> select goods_name from goods where goods_name=null ;
Empty set (0.00 sec)
mysql> select goods_name from goods where goods_name!=null ;
Empty set (0.00 sec)
本文出自 “代码易” 博客,请务必保留此出处http://codeyi.blog.51cto.com/11082384/1732466
''是空字符 相当于在银行有账号,不过没钱
null是空 相当于在银行账号都没有
null比较需要用 is null 或者 is not null 判断
null遇见运算符 一律返回null =null 或 !=null 等等一律返回null ,并且效率不高,所以建表时候一般都会有not null default '';
mysql> select goods_name from goods where goods_name is not null limit 3;
+--------------------+
| goods_name |
+--------------------+
| KD876 |
| htcN85原装充电器 |
| 诺基亚原装5800耳机 |
+--------------------+
3 rows in set (0.00 sec)
mysql> select goods_name from goods where goods_name is null ;
Empty set (0.00 sec)
null 遇见运算符 一律返回null
mysql> select goods_name from goods where goods_name=null ;
Empty set (0.00 sec)
mysql> select goods_name from goods where goods_name!=null ;
Empty set (0.00 sec)
本文出自 “代码易” 博客,请务必保留此出处http://codeyi.blog.51cto.com/11082384/1732466
相关文章推荐
- mysql order by
- mysql having
- 不停止 MySQL 服务增加从库的两种方式
- mysql 统计函数和group by
- MySQL - 复制数据表
- mysql常用字符串函数
- mysql日期时间函数
- mysql的默认排序
- mysql主从同步故障及解决过程
- MYSQL存储过程:批量更新数据
- mysql配置文件my.cnf详解
- wamp中mysqld占用内存过大的解决方法
- 使用mysql5.7.10
- 安装MySQL之后Error2003....不能连接的问题
- mysql版本5.5.x升级到5.6.x步骤分享
- 我的MYSQL学习心得(十四) 备份和恢复
- 我的MYSQL学习心得(十三) 权限管理
- ISO日期格式标准,浏览器到服务器到mysql中的时区
- 我的MYSQL学习心得(十二) 触发器
- hibernate利用mysql的自增长id属性实现自增长id和手动赋值id并存