在oracle中用like模糊搜索不能搜到空值
2017-01-19 09:25
417 查看
实例:
注释:
1、空串对于oracle来说就是null。
2、当name为null时,NVL(name,0)的返回值为0,而0正好符合匹配LIKE '%'这个匹配模式,所以,name为null的数据行可以被查询出来。
SQL> select * from student; ID NAME DEPT ---------- -------------------- ---------- SQL> insert into student values(1,'小米',1); SQL> insert into student values(2,'',2); SQL> insert into student values(3,null,3); SQL> select * from student where name like '%'; ID NAME DEPT ---------- -------------------- ---------- 1 小米 1 SQL> select * from student where name is null; ID NAME DEPT ---------- -------------------- ---------- 2 2 3 3 SQL> select * from student where NVL(name,0) like '%'; ID NAME DEPT ---------- -------------------- ---------- 1 小米 1 2 2 3 3
注释:
1、空串对于oracle来说就是null。
2、当name为null时,NVL(name,0)的返回值为0,而0正好符合匹配LIKE '%'这个匹配模式,所以,name为null的数据行可以被查询出来。
相关文章推荐
- 在oracle中用like模糊搜索时如何使其能搜到空值?
- 在oracle中用like模糊搜索时如何使其能搜到空值
- Oracle模糊查询之(3.2从使用函数和sql语法角度来提高模糊查询效率 二)ORACLE中Like与Instr模糊查询性能大比拼
- Oracle 用Drapper进行like模糊传参查询需要在参数值前后带%符合
- oracle sql语言模糊查询--通配符like的使用教程
- oracle sql语言like模糊查询–通配符(模糊搜索系列一)
- SQL搜索下划线,like中不能匹配下划线的问题
- oracle sql语言模糊查询--通配符like
- Mybatis中oracle、mysql、db2、sql server的like模糊查询
- ORACLE like 下划线 模糊查询 escape
- ORACLE中Like与Instr模糊查询性能大比拼
- Oracle花样查询之LIKE模糊查询
- oracle like模糊查询
- 有些access语句在数据库中可以执行,但是在C#上又不能执行,比如模糊查询-like
- Mybatis中oracle、mysql、db2、sql server的like模糊查询
- oracle - 模糊搜索包含%的记录
- like多字段同时怎么模糊搜索
- SQL搜索下划线,like中不能匹配下划线的问题
- 模糊搜索:concat各种函数详解、like操作符、通配符
- 17、oracle:oracle模糊查询,截取字符串以及搜索字符等函数