Oracle DB SQL 如何设置多个like条件查询数据,oracle字段like多个条件
oracle DB SQL 如何设置多个like条件查询数据&&oracle字段like多个条件
写oracle sql时有时候会有 and (字段 like ‘匹配串1’or 字段 like ‘匹配串2’or ...)这样的情况出现,下面提供一个简洁点的解决方案:
and REGEXP_LIKE(字段名, '(匹配串1|匹配串2|...)') //全模糊匹配
and REGEXP_LIKE(字段名, '^(匹配串1|匹配串2|...)') ';//右模糊匹配
and REGEXP_LIKE(字段名, '(匹配串1|匹配串2|...)$') ';//左模糊匹配
例子:
select org_caller_num,a.org_callee_num,call_seconds,start_time,switch_id,
in_trunk,out_trunk,settle_carrier,file_name
from t_phonebill_201702 a
where exists
(select 1 from security_phonebill_callee_num c where a.org_callee_num
like '%||c.org_callee_num||%') ;
精华版:
select org_caller_num,a.org_callee_num,call_seconds,start_time,switch_id,in_trunk,out_trunk,settle_carrier,file_namefrom t_phonebill_201702 a,security_phonebill_callee_num cwhere a.org_callee_num like '%||c.org_callee_num||%'
赞 (0)