大家好, 我最近有一个问题,请各位解答一个, 谢谢!
A,select * from ab01 t where t.aab001 like '11%' or t.aab001 like 'b11%'
B,select * from ab01 t where t.aab001 like 表达式如何写我要达到的结果是, B语句要只用一个like,用表达式达到A要查到的结果.
A,select * from ab01 t where t.aab001 like '11%' or t.aab001 like 'b11%'
B,select * from ab01 t where t.aab001 like 表达式如何写我要达到的结果是, B语句要只用一个like,用表达式达到A要查到的结果.
只能用正则,不能用like,3楼正解
您好,我现在是多查了一些数据.我要的表达式是:可能b存在,可能b不存在, 但一定要找到以11开头或b11开头的数据
select * from ab01 where regexp_like(a,'^[b]?11')
from ab01 t
where 'b' || replace(substr(aab001, 1, 3), 'b') like 'b11%'你看下这样行么,数据多可能会有性能问题
t.aab001 like 'b11%' 是 t.aab001 like '11%'的子集,两者或起来就是取最大集,等价于t.aab001 like '11%'。所以B:select * from ab01 t where t.aab001 like '11%'
OVER!!!
FROM AB01 T
WHERE SUBSTR(T.AAB001, 1, 3) LIKE '%11%'
AND SUBSTR(T.AAB001, 1, 1) IN ('b', '1')
我就郁闷了这样不能达到效果?with ab01 as (select 'b1111a' aab001 from dual
union
select '111a' from dual
union
select '1a1b' from dual)
select *
from ab01 t
where 'b' || replace(substr(aab001, 1, 3), 'b') like 'b11%'
union
select '1b1' from dual
union
select '11aa' from dual
union
select '11b' from dual)
select *
from ab01 t
where replace(substr(aab001, 1, 1), 'b')||substr(aab001,2,2) like '11%'
select * from ab01 t where decode(substr(t.aab001, 1, 3), 'b11', '11', substr(t.aab001, 1, 2)) = '11';