本帖最后由 kn9zxs88 于 2013-09-04 15:46:15 编辑

解决方案 »

  1.   

    select xxzx  from A(nolock) where zzxz like '1%'
      

  2.   


    谢谢您的建议,上面的字段写漏了一个,如果字段中单独是 10,那您的语句也会将 10 取出select xxzx  from A(nolock) where zzxz like '1,%'
      

  3.   


    谢谢您的建议,上面的字段写漏了一个,如果字段中单独是 10,那您的语句也会将 10 取出select xxzx  from A(nolock) where zzxz like '1,%'再请教下,如果X=2,想要包含 2 的记录呢?
      

  4.   


    谢谢您的建议,上面的字段写漏了一个,如果字段中单独是 10,那您的语句也会将 10 取出select xxzx  from A(nolock) where zzxz like '1,%'再请教下,如果X=2,想要包含 2 的记录呢?select xxzx  from A(nolock) where zzxz like '2,%' or zzxz like '%,2,%'
      

  5.   

    if OBJECT_ID('#tb','u') is not null  drop table #tb
    go
    create table #tb(xxzz varchar(50))insert #tb
    select '51,52,2' union all
    select '1,2,3,51,52' union all
    select '1,2,3' union all
    select '1,10' union all
    select '1,3,2' union all
    select '1,3' union all
    select '2,51,52' union all
    select '2,51,52' union all
    select '3,48,41,50' union all
    select '3,41,48,50' union all
    select '1,8' union all
    select '1' select * from #tb where  CHARINDEX(',1',','+xxzz)>0