where 8 in (caid)群众caid是数据库的字段 里面的数据是类似(1,2,4,8,5)是string型(我这caid是类别的多选保存类别的id)现在问题是where 8 in (caid)查询不出数据来,但库里面有是8跟前面的8对应
不知道为什么

解决方案 »

  1.   


    where charindex('8',caid)>0
    或者
    where caid like '%8%'
      

  2.   

    你传入的string类型被当成一个字符串了,in里面只相当于有一个string类型的值,而不是数字的集合。这样要实现可以用CHARINDEX('8',string) > 0 来实现
      

  3.   

    where charindex('8',caid) > 0 
      

  4.   

    where charindex(',8,',','+caid+',') > 0 
      

  5.   

    where charindex('8',caid)>0
    这样还是不行
      

  6.   

    where caid like '%8%'
    这样也是搜索不出来,因为caid里是这样保存数据:caid(1,2,4,8,5)
      

  7.   

    where charindex('8','1,6,8,3') > 0---------这样可以
    where charindex('8',caid)>0----------------这样不可以为什么啊?
      

  8.   


    打一个具体的card值出来
    card='1,6,8,3' ?