sql 语句 c.id is null 与 id = ''

许久没有写过SQL语句了,连关键词也都忘的一干二净了。


今天做项目 (Heal Your Body)的时候,发现数据显示与iPhone那边显示的不一致。详细检查了自己的sql ,发现sql书写完全正确,不知道为什么query的时候,漏了两条数据。


通过肉眼观察,这两种数据完全满足sql里面的条件语句。不知道为什么一直就是查不出来。


完整的sql语句:

select a.id, (select b.problem from bookdata as b where b.id=a.subidof) || ' ' || a.problem as problem from bookdata as a where a.subidof <> '' union all select c.id, c.problem as problem from bookdata as c where c.subidof is null and (c.Cause is not null or c.Cure is not null or c.seeNext is not null ) order by problem asc;


通过拆分sql语句后意外发现:

select c.id, c.problem as problem from bookdata as c where c.subidof is null and (c.Cause is not null or c.Cure is not null or c.seeNext is not null ) order by problem asc;

此句执行的时候,也查不出那两条数据。

再简化:

select c.id, c.problem as problem from bookdata as c where c.subidof is null ;


发现,还是会漏掉两条数据。 ---- (第65,68条)


再通过 :

select c.id, c.problem as problem from bookdata as c where c.subidof = '';

查出仅的那两种漏掉的数据。


原来你通过肉眼看到(SQLite Database browser 或者 Sqlite Administer工具 )的某些字段是空的,其实不一定是空的,它也许 is null,也许是 ‘’


soluton:修改数据库中的‘脏数据’







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值