给出一个id2的行如:1,2,3的字符串id2s,--------id2s是指什么,是那一个列的内容

解决方案 »

  1.   


    select id1 from table2
    where charindex(','+convert(varchar(10),id2)+',',','+id2s+',')>0
    and flag =0
      

  2.   

    id2s 是列id2的一个集合串:'1,2,3',表示id2为1、2、3的行
    要求先找出id2s对应的所有的distinct id1
    然后从这些id1中找出 not exists (select 1 from table2 where flag=1 and id1=@id1)的所有id1
      

  3.   

    id2s 是列id2的一个集合串:'1,2,3',表示id2为1、2、3的行
    要求先从table2找出id2s对应的所有的distinct id1
    然后从这些id1中找出
    对于每个id1:@id1,找出 not exists (select 1 from table2 where flag=1 and id1=@id1)的所有id1不知表述清楚没有
      

  4.   

    declare @id2s varchar(100)
    set @id2s='1,2,3'
    select distinct id1 from table2 
    where charindex(','+convert(varchar,id2)+',',','+@id2s+',')>0 
          and
          flag=0