表名: [abc]字段: id ,titleid title
1 10,20,30,2010,2020只查找 title包含20的, 2010,2020这样的算。求助怎么写SQL语句。
~~~~(>_<)~~~~ ~~~~(>_<)~~~~ ~~~~(~~~~(>_<)~~~~ >_<)~~~~ ~~~~(>_<)~~~~
1 10,20,30,2010,2020只查找 title包含20的, 2010,2020这样的算。求助怎么写SQL语句。
~~~~(>_<)~~~~ ~~~~(>_<)~~~~ ~~~~(~~~~(>_<)~~~~ >_<)~~~~ ~~~~(>_<)~~~~
where charindex(',20,',','+title+',')>0
select * from abc where charindex('20',title)>0
那就是下面的:
SQL code
select * from tb
where charindex('20',title)>0
insert @gg values(1,'2010,1201,1120,2130,2103')
insert @gg values(2,'2130')
insert @gg values(3,'2010')
insert @gg values(4,'1120,5555')
insert @gg values(5,'1122,1202')--语句1
select * from @gg
--语句2
select * from @gg where charindex(',20,',','+col+',')>0
--语句3
select * from @gg where col like '%20%'貌似语句2有问题 得不到要的结果,
语句3可行