select id from A where instr(list,'6')>0

解决方案 »

  1.   

    bzszp(SongZip)你可能没明白我的意思,我是说list的值并不固定,b的值也不一定,只要b的值在list那个字符串里面就取出来。
      

  2.   

    create or replace function get(p_b in varchar2) return number is
     
    cursor t_sor is
    select list from A;
    begin
    for v_sor in t_sor loop
     if substr(v_sor.list,1,1)=p_b then
       return(1);
     elsif substr(v_sor.list,instr(v_sor.list,',')+1,1)=p_b then
       return(1);
     elsif substr(v_sor.list,instr(v_sor.list,',',1,2)+1,1)=p_b then
       return(1);
     elsif substr(v_sor.list,instr(v_sor.list,',',1,3)+1,1)=p_b then
      return(1);
     else
      return(null);
     end if;
    end get;
    /select id from a where get(b)=1;
      

  3.   

    sorry.........
    enf if;
    end loop;--多加此语句
      

  4.   

    list的值固不固定没关系呀,反正SQL里写的是字段名,你把b写成变量就OK了!在程序里直接写好办,如果在ORACLE里面就用动态SQL!