单纯的sql语句不能解决,写一个函数。
例如:
SQL> select col from tb;COL
------------------------------
a,b,c,e
d,e,f
l,i,jSQL> create or replace function f_demo(v_col varchar2,v_str varchar2)
2 return varchar2
3 as
4 v_temp varchar2(20);
5 v_c varchar2(10);
6 begin
7 v_temp:=v_str||',';
8 while instr(v_temp,',')>0 loop
9 v_c:=substr(v_temp,1,instr(v_temp,',')-1);
10 if instr(v_col,v_c)>0 then
11 return 'true';
12 end if;
13 v_temp:=substr(v_temp,instr(v_temp,',')+1);
14 end loop;
15 return 'false';
16 end f_demo;
17 /函数已创建。SQL> select f_demo(col,'a,e') from tb;F_DEMO(COL,'A,E')
---------------------------------------------------------------------------
true
true
falseSQL>
例如:
SQL> select col from tb;COL
------------------------------
a,b,c,e
d,e,f
l,i,jSQL> create or replace function f_demo(v_col varchar2,v_str varchar2)
2 return varchar2
3 as
4 v_temp varchar2(20);
5 v_c varchar2(10);
6 begin
7 v_temp:=v_str||',';
8 while instr(v_temp,',')>0 loop
9 v_c:=substr(v_temp,1,instr(v_temp,',')-1);
10 if instr(v_col,v_c)>0 then
11 return 'true';
12 end if;
13 v_temp:=substr(v_temp,instr(v_temp,',')+1);
14 end loop;
15 return 'false';
16 end f_demo;
17 /函数已创建。SQL> select f_demo(col,'a,e') from tb;F_DEMO(COL,'A,E')
---------------------------------------------------------------------------
true
true
falseSQL>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货