create table mytab(id int identity , name varchar(50))
这个表,第一个是自动编号的,
我现在有这样一个字符串
"1,2,3,6,9,4,5"
怎么可以查询出包含这些数字的记录来?
select * from mytable id in '1,2,3,6,9,4,5'
这样写不对呀,怎么搞?
高手帮助

解决方案 »

  1.   

    select * from mytable id = '1,2,3,6,9,4,5' 
      

  2.   

    select * from mytable where charindex('1,2,3,6,9,4,5',name)>0
      

  3.   

    楼上两个都是设么玩意???
    我问的是sqlserver的东西
      

  4.   

    select * from mytable where id in (1,2,3,6,9,4,5)
      

  5.   

    select * from mytab where id like '%[1,2,3]%'
      

  6.   

    declare @ids varchar(1000)
    set @ids = '1,2,3,6,9,4,5'
    exec ('select * from mytable where id in ('+@ids+')')