27,579
社区成员
发帖
与我相关
我的任务
分享
if object_id('tableA') is not null
drop table tableA
go
create table tableA
(
id varchar(20)
)
go
insert into tableA
select '30' union all
select '40' union all
select '41' union all
select '30,40,41'
go
select * from tableA where ','+id+',' like '%,30,%'
/*
(4 行受影响)
id
--------------------
30
30,40,41
(2 行受影响)
*/
select * from tableA where 1 = 1 and charindex(',30,' ,','+ltrim(id)+',')>0
select * from tableA
where 1 = 1
and ',30,' like ','+ltrim(id)+','
select * from tableA
where 1 = 1
and id like '%30%'