select * from emp where comm like '%0%' or nvl2('a',0,1)=1; select * from emp where comm like '%%' or nvl2(null,0,1)=1;
where 字段 like '模糊匹配' or 字段is null;
参数为NULL和不为NULL的情况,写到程序中,参数化就OK了 select * from emp where comm like '%0%' or nvl2('0',0,1)=1; select * from emp where comm like '%%' or nvl2(null,0,1)=1;
where 字段 like '%字符串%' or 字段is null;
where 字段 like '模糊匹配' or 匹配 is null;
判断一下有没有输入不就可以了,类似这样(输入 is not null and 字段 like 输入||'%') or (输入 is null and 字段 is null)
select * from emp where comm like '%%' or nvl2(null,0,1)=1;
select * from emp where comm like '%0%' or nvl2('0',0,1)=1;
select * from emp where comm like '%%' or nvl2(null,0,1)=1;