当前位置: 代码迷 >> Sql Server >> SQL查看包括这个字符解决方法
  详细解决方案

SQL查看包括这个字符解决方法

热度:0   发布时间:2016-04-24 23:47:19.0
SQL查看包括这个字符
本帖最后由 chinaboykai 于 2013-01-17 12:00:23 编辑

查找出 有 AreaID 字段中有  6 的 userid 编号
SQL查询

------解决方案--------------------
看错,继续。


select *
from tb
where charindex(',6,',','+AreaID+',') > 0

------解决方案--------------------
select userid from 表名 where areaid like '%6,%' 
or areaid like '%,6,%' 
or areaid like '%,6%'
or areaid = '6'
------解决方案--------------------
--更正一下,patindex漏打了%
或用patindex/charindex
 
select * from 表 where charindex(',6,',','+AreaID+',')>0
select * from 表 where patindex('%,6,%',','+AreaID+',')>0
  相关解决方案