select title from depname where charindex( ','+title+',',',a,b,c,d,e,f,g,h,' )>0

解决方案 »

  1.   

    select title from depname where charindex(title,'a,b,c,d,e,f,g,h')>0
      

  2.   

    不在的话是"="吧select title from depname where charindex( ','+title+',',',a,b,c,d,e,f,g,h,' )=0
      

  3.   

    写的有点快了吧.还没问清楼主他的title是怎么存的.如果是单值那么没问题.否则...比如
    title
    a,b
    d,a
    b,c
      

  4.   

    字符串“a,b,c,d,e,f,g,h,%”
    现在需要判断select title from depname 选出来的值在不在上面的字符串中,如果在则选出来,如果不在则不选出来,% 是任何title都选择。
      

  5.   

    应该是二楼,一楼把SQL语句的查询范围拓宽了
      

  6.   

    楼上的你必须考滤,title中的多个值出现的顺序不按照 列表中的那些值出现的顺序.
      

  7.   

    自己解决。
    select * from A_JG where dqid like @dqid and( (charindex(convert(char,dqid),@dqid_sql )>=0) or (charindex('%',@dqid_sql )>=0) )