select * from 表 where charindex(',000003000001000001,',','+code+',')>0

解决方案 »

  1.   

    select * 
    from table
    where charindex('000003000001000001',code ) > 0
      

  2.   


    create table tt (id int, code varchar(50))insert tt select 16,'000003000001000001'
    insert tt select 17,'000003000001000001,000003000002'
    insert tt select 18,'000003000001000001,000003000002,000004000001'
    insert tt select 19,'000003000002,000004000001'declare @tmp varchar(50)
    set @tmp='000003000001000001'
     select * from tt where charindex(code,@tmp)>=0
    id             code
    16 3000001000001
    17 000003000001000001,000003000002
    18 000003000001000001,000003000002,000004000001
      

  3.   

    如果就查询只有'3000001000001'数据
    declare @tmp varchar(50)
    set @tmp='000003000001000001'
     select * from tt where charindex(code,@tmp)>0