表名: [abc]字段: id ,titleid   title
1    10,20,30,2010,2020只查找 title包含20的,  2010,2020这样的算。求助怎么写SQL语句。
~~~~(>_<)~~~~ ~~~~(>_<)~~~~ ~~~~(~~~~(>_<)~~~~ >_<)~~~~ ~~~~(>_<)~~~~ 

解决方案 »

  1.   

    select * from tb
    where charindex(',20,',','+title+',')>0
      

  2.   

    2010,2020这样的算???
    select * from abc where charindex('20',title)>0
      

  3.   

    where title like '%20%'
      

  4.   

    2020也算啊?
    那就是下面的:
    SQL code
    select * from tb
    where charindex('20',title)>0
      

  5.   

    declare @gg table(id int,col varchar(200))
    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可行
      

  6.   

    2020不算的话select * from @gg where col like '%,20,%'