查询数据 条件 货号=32915-000000762 这个的商品
如果全部输入,可以查询
这样输入32915762 ,就不能查询处结果,郁闷!
输入32915762  就直接能查询处结果?

解决方案 »

  1.   

    where 货号 like '%32915-000000762%'
      

  2.   

    select * from  tb where 货号 like '32915%762%' 
      

  3.   


    --楼主的SQL语句是什么?没有使用模糊查询吧!like '%32915762%'
      

  4.   

    declare @s varchar(10)
    set @s='32915762'
    select * 
    from tb 
    where replace(replace(货号,'-',''),'0','')=@s
      

  5.   

    select *
    from tb
    where 
      left(货号,charindex('-',货号)-1)+ltrim(cast(right(货号,len(货号)-charindex('-',货号)) as int))='32915762'
      

  6.   


    where 货号 like '32915%762%'
      

  7.   

    replace 0 显然是不行的,如果后面的数字是702就不行了
      

  8.   

    用replace 把0替换了,万一里面有的0不用替换,就不对了
    所有要看具体要求
      

  9.   


    where 货号 like '32915%762' 或者将列中的0去掉,如楼上所说。
      

  10.   

    declare @t table(f1 varchar(15))insert @t
    select '32915-000000762' union all
    select '32915-000000763' union all
    select '32915-000000764' union all
    select '32915-000000765'declare @str varchar(15)
    set @Str='32915762'
    set @str=left(@Str,5)+'-'+right('000000000'+substring(@Str,6,15),9)print @Strselect *
    from @t
    where f1=@str