查出cx包裹5的...但是不要查出来15,25,35,之类的
1L正解我蹭分
SQL code:
--> 测试数据:[tb]
if object_id('[tb]') is not null drop table [tb]
go
create table [tb](cx varchar(8))
insert [tb]
select '1,' union all
select '5,12' union all
select '15,23,' union all
select '25,35,' union all
select '55,105' union all
select '2,3,4,5,' union all
select '5,'
--------------------------------查询开始------------------------------
select * from [tb] where charindex(',5,',','+cx)>0
/*
(7 行受影响)
cx
--------
5,12
2,3,4,5,
5,
(3 行受影响)
*/
SQL code:
select * from [tb] where ',5,' like '%'+','+cx+','+'%'
SQL code:
select * from table
where charindex(',5',cx)>0
--改下
SQL code:
select * from table
where charindex(',5,',cx)>0
SQL code:
--or
select * from [tb] where ','+cx like '%,5,%'
{{----