例如,字段TXT,存储的值如下,
123,523
1236,4356
784562,5456
582933,4356
以上四条记录中每一组中都有一个,号分隔,
现在指定值如;2,3
怎么判断每个字段中是否存在2跟3,2与3的位置也要配对,2是前面那个,3在逗号后面那组中
如果记录中存在指定的值,那么将本条记录的另一个字段hit中的值更新了真True,否则更新为假

解决方案 »

  1.   

    update tb set hit=true where charindex('2',left(TXT,charindex(',',TXT)-1))>0
         and charindex('3',right(TXT,len(TXT)-charindex(',',TXT)))>0
      

  2.   

    update tb
    set hit = (case when charindex(',2,3,' , ',' + txt + ',') > 0 then 'true' else 'false' end)
      

  3.   

    一二楼结合一下
    update tb
    set hit = (case when charindex('2',left(TXT,charindex(',',TXT)-1))>0
         and charindex('3',right(TXT,len(TXT)-charindex(',',TXT)))>0
     then 'true' else 'false' end) 
      

  4.   

    update Sscbetting
    set zhangtai=(case when charindex('5',left(hm,charindex(',',hm)-1))>0
         and charindex('6',right(hm,len(hm)-charindex(',',hm)))>0 then 'true' else 'false' end)
    结合两位高手的回答,更新真假已经可以了,但是如果某条被标记为真,则向另一个表中添加一条通知,这个应该怎么做?