关于Oracle的where条件有特殊符号的处理
关于Oracle的where条件有特殊符号的处理
有这样的一些数据:
select 'fie_a' as col from dual
union all
select 'fie_b' as col from dual
union all
select 'fi_a' as col from dual
union all
select 'fi_b' as col from dual;
我需要从这些数据中查找fi_开头的数据,一般写法是:
select *
from (
select 'fie_a' as col from dual
union all
select 'fie_b' as col from dual
union all
select 'fi_a' as col from dual
union all
select 'fi_b' as col from dual
) t
where t.col like 'fi_%';
但这样写并不能得到我们想要的结果,那么我们需要作如下处理:
select *
from (
select 'fie_a' as col from dual
union all
select 'fie_b' as col from dual
union all
select 'fi_a' as col from dual
union all
select 'fi_b' as col from dual
) t
where t.col like 'fi\_%' escape '\';