表 mytableid     cityId
1       1,2,3
2       2,3,7
3       3,6,8
4       1,2,5
如果想查找 cityId 字段里包含 "5" 数据怎么办?? 帮忙(最好不要用like)

解决方案 »

  1.   

    不想用LIKE那就用charindex
    select * from mytable where charindex('y',cityId)>0
      

  2.   

    更改一下。
    select * from mytable where charindex('5',cityId)>0
      

  3.   

    SELECT * FROM T1
    WHERE CHARINDEX('5', cityId)>0
      

  4.   

    那如果 cityid 中有 15,25,35 时 是不是搜索的不准确?
      

  5.   

    select * from mytable where charindex('15',cityId)>0
    select * from mytable where charindex('25',cityId)>0
    ......
      

  6.   

    select * from mytable where charindex(',5,',','+cityId+',')>0