我有一批需要读取的数据 已知这些AUTOID
组织后为 1,2,3,4,5
现在想一次性将这些数据读出
有没有可能用
select * from table where autoid in()这个语句来写
该怎么写?

解决方案 »

  1.   


    select * from table where autoid in(1,2,3,4,5)
      

  2.   

    select * from table where charindex('1,2,3,4,5',autoid)>0
      

  3.   

    select * from table where CHARINDEX(','+LTRIM(autoid)+',' ,',1,2,3,4,5,')>0
      

  4.   

    select * from tb
    where CHARINDEX(','+LTRIM(autoid)+',' ,',1,2,3,4,5,')>0
      

  5.   

    用的就是1楼的方法 检查了一下 出错原因是加个对引号进去 呵呵
    不知道后面几位用CHARINDEX是为了避免什么样的情况呢?