如题。有个数值型字段,想搜素这个字段中包含某个数值(如11或14.76)的所有记录,请问如何实现?

解决方案 »

  1.   

    select * from tb where col=11 or col=14.76
      

  2.   


    select  w.*
    from table_a w
    where instr(w.price,11)>0
      

  3.   


    select  w.*
    from table_a w
    where instr(w.price,11)>0
       or instr(w.price,14.76)>0
      

  4.   


    --匹配:
    SQL> with t as(
      2       select 1 col_1,1256 col_2 from dual union all
      3       select 2,11 from dual union all
      4       select 3,14.76 from dual union all
      5       select 4,114.7698 from dual union all
      6       select 5,1111.0011 from dual
      7       )
      8  select * from t
      9  where col_2 like '%11%' or
     10        col_2 like '%14.76%'
     11  /     COL_1      COL_2
    ---------- ----------
             2         11
             3      14.76
             4   114.7698
             5  1111.0011
      

  5.   


    SQL> with t as(
      2       select 1 col_1,14117 col_2 from dual union all
      3       select 2,1714.768 from dual union all
      4       select 3,840 from dual union all
      5       select 4,790 from dual union all
      6       select 5,113.67 from dual union all
      7       select 6,67.6 from dual
      8       )
      9  select * from t
     10  where col_2 like '%11%' or
     11        col_2 like '%14.76%'
     12  /     COL_1      COL_2
    ---------- ----------
             1      14117
             2   1714.768
             5     113.67
      

  6.   

    非常感谢,用instr函数确实能解决问题。