create table T(book_name nvarchar(10), book_ztid varchar(20))
insert T select'Book Title A', '4'
union all select'Book Title B', '2,4,5'
union all select'Book Title C', '3,5,14,24,25,34'
union all select'Book Title D', '4,24'
select * from T
where charindex(',4,',','+book_ztid+',')>0
--result
book_name book_ztid
---------- --------------------
Title A 4
Title B 2,4,5
Title D 4,24
(3 row(s) affected) |