现在我的查询中我想查询 15%的数据,但是sql会把这个百分号认为是通配符,可是我就是想查询等于15%的数据,怎么办啊

解决方案 »

  1.   

    只有like运算符才会把%当成通配符吧?=是不会的吧?
      

  2.   

    create table #(a varchar(20))
    insert into # select '15%'select * from # where a='15%'可以阿
      

  3.   

    select * from tablename where column like '%15[%]%'
      

  4.   

    那再加一个不就行了?
    select * from # where a like '15%%'
      

  5.   

    TO:jacobsan(梅) 
    这样会把包含15的数据也查询出来
      

  6.   


    select * from
    (
    select col='15'
    union all select '%15%'
    union all select '%15'
    union all select '15%'
    ) a
    where a.col='15%'--result
    col  
    ---- 
    15%(1 row(s) affected)
      

  7.   

    例子: select * from tablename where column like '%[%]%'   --这样就可以找出某一列中含有'%'的行了用中括号‘[]’把‘%’扩起来就认为是普通字符了
      

  8.   

    为什么不用charindex()函数呢?select * from # where charindex('15%',a)>0
      

  9.   


    select * from
    (
    select col='15'
    union all select '%15%'
    union all select '%15'
    union all select '15%'
    ) a
    where a.col like '%[%]%'
      

  10.   

    select * from a where [name] like '%15[%]%'
    select * from A  where charindex('15%',[name])>0 对
      

  11.   

    使用 ESCAPE 关键字定义转义符。在模式中,当转义符置于通配符之前时,该通配符就解释为普通字符。例如,要搜索在任意位置包含字符串 5% 的字符串,请使用: 
    WHERE ColumnA LIKE '15/%%' ESCAPE '/' 
      

  12.   

    使用 ESCAPE 关键字定义转义符。在模式中,当转义符置于通配符之前时,该通配符就解释为普通字符。例如,要搜索在任意位置包含字符串 15% 的字符串,请使用: 
    WHERE ColumnA LIKE '%15/%%' ESCAPE '/'