首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

现在用sql语句查出来字段里包含某个字符串的所有记录如何查

2012-12-19 
现在用sql语句查出来字段里包含某个字符串的所有记录怎么查?这是一样表tableidtitle121221321,45,78447,21

现在用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,%'

[解决办法]
select *
from table
where title='21' or title like '%,21' or title like '%,21,%' or title like '21,%'
[解决办法]
--2
select * from tb where charindex(',21,',','+title+',')>0

[解决办法]
我只查  21 想 221这样的我不要,用like 查询就把221 这样的查询出来了,所以不行
[解决办法]
再声明一下 是 mysql
[解决办法]
select * from dede_archives where FIND_IN_SET('21',title) 这样就行了,mysql 的 谢谢各位的参与
[解决办法]
引用:
select * from dede_archives where FIND_IN_SET('21',title) 这样就行了,mysql 的 谢谢各位的参与

解决了就好,下次提问记得说明sql 版本 
[解决办法]
谢谢提醒!

热点排行