现在用sql语句查出来字段里包含某个字符串的所有记录怎么查?
这是一样表 table
id title
1 21
2 21
3 21,45,78
4 47,21,23
5 211,45,74
6 34,321
现在用sql语句查出来字段里包含21的所有记录怎么办?
想321 还有 211 这样的记录不能要。
在线等,急需
[解决办法]
能有结果必定重谢
[解决办法]
select *
from table
where title=21 or title like '%,21' or title like '%,21,%' or title like '21,%'
[解决办法]
select * from tb where ','+title+',' like '%,211,%'
--2
select * from tb where charindex(',21,',','+title+',')>0