oracle xx is not null and xx !=‘‘ 查不到数

前端时间刚写了一条sql查不到数据

select  * from  (
    select * from  PAT_RESPIRE_FIXED_RECORD where  patId = '20230522112223142699'
    and VENTILMODE is not null and  VENTILMODE != ' '
  order by OPERATETIME desc ) y where  ROWNUM = 1

原因 :当数据为'' 的时候,在数据库中会被自动设置成null,也许是因为数据库中就没有''这个东西,所以设置成查不到(具体的底层原因没有查阅过)

处理方式: 在''中加上一个空格即可。   and VENTILMODE is not null and  VENTILMODE != '  '

你可能感兴趣的:(Bug记录,开发记录,oracle,数据库)