最后一句的毛病吧select 'ok'  where 12 in (select b from #t where a=1)

解决方案 »

  1.   

    select 'ok'  where exists(select 1 from b where charindex('12',b)>0 and a=1)
      

  2.   

    select 'ok'  where exists(select 1 from b where charindex(',12,',','+b+',')>0 and a=1)
      

  3.   

    非常感谢,为什么用convert把int变成char还不可以呢?
    select 'ok'  where convert(varchar(100),12) in (select b from #t where a=1)
      

  4.   

    回复人: yuekai(tiger) ( ) 信誉:100  2005-02-17 11:26:00  得分: 0  
     
     
    非常感谢,为什么用convert把int变成char还不可以呢?
    select 'ok'  where convert(varchar(100),12) in (select b from #t where a=1)这样写语法没有错误,但是逻辑上是不对的b的值是  '12,2345,56,587,67,1' ... 类似这样,用这样一个值和'12'去比较当然不会相等了