举例:
![](file:///C:Userschaoqun.guoDocumentsTencent Files815202984ImageGroupImage18JUSA207LQ~F[6XG{VFK~E{A.png)
我如果直接charindex,那么11,12也会被包含。
解决(1):
select * from ( select '1,2,12,111' as str union all select '2,12,111' union all select '1' ) t1 where ','+str+',' like'%,1,%'
解决(2):
利用如mysql中的find_in_set办法
自己写一个自定义函数split,利用outer apply,这个比较简单,这里不做赘述。
split 函数 可以参考:https://www.cnblogs.com/gered/p/9887536.html