作者joedenkidd (优质的蓝色射手)
看板Database
标题[SQL ] 资料查寻问题
时间Thu Jan 11 19:27:31 2018
资料库名称:postgresql
资料库版本:8.4
内容/问题描述:
小弟有个table,栏位属性是是text,存的资料是日期且有部分栏位是有空值的, 存的格式
如下
2018/1/2
2018/12/1
2018/10/2
用
select * from table where date(date) between date(2018/1/1) and
date(2018/2/1)
会出现error 栏位有空值的错误,想说用
select * from table where (date(date) between date(2018/1/1) and
date(2018/2/1)) and date !=''
会出现一样的问题,看来关念有误
麻烦各位高手指点,感谢
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 118.169.8.57
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Database/M.1515670054.A.AA5.html
1F:→ wei10cool: is not null 01/12 00:50
2F:推 billy522: 或是 and coalesce(date,'') != '' 01/12 07:36
3F:→ joedenkidd: 感谢 is not null 之前试过不行,刚试ㄌ coalesce可以 01/13 13:37