select * from table where col in (1,4,5) or col in (1,2,5);
select * from table1 where col=some(传进来的字符串);
不确定具体值,那只有动态SQL了
创建判断函数 create or replace function is_have(P_col varchar2, P_condition varchar2) /*p_col标识对应的数据列;P_condition标识条件字符串*/ return number is v_flag number := 0; begin for x in (select regexp_substr(P_condition, '[^,]+', 1, rownum) as col from dual connect by rownum <= length(regexp_replace(P_condition, '[^,]', null))) loop if instr(P_col, x.col) > 0 then v_flag := 1; end if; end loop; return v_flag; end; 测试语句 select * from (select '1,2,3,4,5' as col from dual) where 1=is_have(col,'1,3');
select * from table where col in (1,4,5) or col in (1,2,5);
create or replace function is_have(P_col varchar2, P_condition varchar2)
/*p_col标识对应的数据列;P_condition标识条件字符串*/
return number is
v_flag number := 0;
begin
for x in (select regexp_substr(P_condition, '[^,]+', 1, rownum) as col
from dual
connect by rownum <=
length(regexp_replace(P_condition, '[^,]', null))) loop
if instr(P_col, x.col) > 0 then
v_flag := 1;
end if;
end loop;
return v_flag;
end;
测试语句
select * from (select '1,2,3,4,5' as col from dual) where 1=is_have(col,'1,3');