
查找出 有 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