34,575
社区成员
发帖
与我相关
我的任务
分享
select *
from tb
where charindex(',8,' , ',' + txt + ',') > 0
create table tb(Id int, Txt varchar(50))
insert into tb values(1, '1,2,3,6,26')
insert into tb values(2, '3,5,6,8,9,41,5')
insert into tb values(3, '8,9,18,20')
go
select * from tb where charindex(',8,' , ',' + txt + ',') > 0
drop table tb
/*
Id Txt
----------- --------------------------------------------------
2 3,5,6,8,9,41,5
3 8,9,18,20
(所影响的行数为 2 行)
*/
select * from tb where charindex(',8,' , ',' + txt + ',') > 0