Oracle select 字符串处理
现有表A A中有字段名为a1的列
a1列的取值范围为 【2 3 5 82 80】
取值为这五个数的任意组合,至少包含一个数字;若有多个数字,中间使用“,”连接
现有字符串 5,82
需要从A表中选取a1列中的值包含5或者82的所有行
select * from A
where
...
a1的值包含5或者82
...?
求教啦,请各位大神不吝赐教!先谢谢啦!
[解决办法]
select * from A where ','
[解决办法]
a1
[解决办法]
',' like '%,5,%' or ','
[解决办法]
a1
[解决办法]
',' like '%,82,%'
select distinct t1.a1
from a t1,
(select REGEXP_SUBSTR('2,3,5,82,80', '[^,]+', 1, LEVEL) str
from dual
CONNECT BY LEVEL <= REGEXP_COUNT('2,3,5,82,80', ',') + 1) t2
where t1.a1 like '%'
[解决办法]
t2.str
[解决办法]
'%';