免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6419 | 回复: 5
打印 上一主题 下一主题

mysql的text字段没有默认值,select的时候要选 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-01-08 13:54 |只看该作者 |倒序浏览
5可用积分
table aaa
字段   description   text类型

select * from aaa where description=""


如果insert的时候没有管这个字段的话,选不出来

最佳答案

论坛徽章:
1
白银圣斗士
日期:2015-11-23 08:33:04
2 [报告]
发表于 2010-01-08 13:54 |只看该作者
is null

论坛徽章:
0
3 [报告]
发表于 2010-01-08 13:55 |只看该作者
更诡异的是运行

select count(*) from aaa where description=null

select count(*) from aaa where description<>null

返回结果都是0

论坛徽章:
0
4 [报告]
发表于 2010-01-08 14:02 |只看该作者
多谢,呵呵,懂了
select count(*) from aaa where description=null
被认为是select count(*) from aaa where description='null'




而select count(*) from aaa where description<>null
是与select count(*) from aaa where description is null相对

论坛徽章:
0
5 [报告]
发表于 2010-01-08 16:13 |只看该作者
原帖由 b02213131 于 2010-1-8 14:02 发表
多谢,呵呵,懂了
select count(*) from aaa where description=null
被认为是select count(*) from aaa where description='null'




而select count(*) from aaa where descriptionnull
是与select  ...




快给版主积分,哈

论坛徽章:
8
综合交流区版块每周发帖之星
日期:2015-12-02 15:03:53数据库技术版块每日发帖之星
日期:2015-10-02 06:20:00IT运维版块每日发帖之星
日期:2015-10-02 06:20:00IT运维版块每日发帖之星
日期:2015-09-14 06:20:00金牛座
日期:2014-10-10 11:23:34CU十二周年纪念徽章
日期:2013-10-24 15:41:34酉鸡
日期:2013-10-19 10:17:1315-16赛季CBA联赛之北京
日期:2017-03-06 15:12:44
6 [报告]
发表于 2010-01-11 16:39 |只看该作者
原帖由 b02213131 于 2010-1-8 14:02 发表
多谢,呵呵,懂了
select count(*) from aaa where description=null
被认为是select count(*) from aaa where description='null'




而select count(*) from aaa where descriptionnull
是与select  ...


文档中有专门解释null的部分
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP