小弟的sql如下:
select * from table where table.a like '%S2005%',这时的查询结果为空,我看了一下数据库,发现字段a中的S和2005中间是有回车符的,如果写成select * from table where table.a like '%S%',就能查到数据。如何处理才能让select * from table where table.a like '%S2005%'也可以查询出数据,我用的是oracle数据库。 谢谢了先!

解决方案 »

  1.   

    select * from table where table.a like '%S%2005%';多加一个%就行
      

  2.   

    tmdxht(弄不明白):你好,%%中间的字符串是用户自己输入的,我的想法是能不能对字段a做一个处理。
      

  3.   

    create or replace function uf_trim(v_str in varchar2) return varchar2 is
    Result       varchar2(255);
    v_len        number(5);
    v_str_change varchar2(255);
    v_str_new    varchar2(255);
    j            number(5);
    begin
    Result       := '';
    v_str_change:=rtrim(ltrim(v_str));
    v_len:=length(v_str_change);
    j            := 1;
    while j<=v_len loop
    v_str_new:=substr(v_str_change,j,1);
    result:=result||rtrim(v_str_new);
    j:=j+1;
    end loop;
    return result;
    end;SQL> select uf_trim('1    黄 656 ') from dual;UF_TRIM('1黄656')
    --------------------------------------------------------------------------------
    1黄656希望能有点帮助!
      

  4.   

    select * from table where table.a like '%S_2005%'
    用  '_'  表示占位