select * from table
where charindex(',d,',','+danwei+',')>0

解决方案 »

  1.   

    --建立测试环境
    Create Table 表(id varchar(10),danwei varchar(10))
    --插入数据
    insert into 表
    select '23','a,b' union
    select '24','c' union
    select '25','b,d' union
    select '26','a,c,d' union
    select '27','d'--测试语句
     select * from 表 where ','+danwei+',' like '%,d,%'
     
    --删除测试环境
    Drop Table 表/*
    id         danwei     
    ---------- ---------- 
    25         b,d
    26         a,c,d
    27         d
    */
      

  2.   

    Select ID,danwei from 表 Where CharIndex('d',danwei)>0
      

  3.   

    select * from table where charindex(',d,',','+danwei+',') > 0