應該這樣寫:
select id from table where alive in(111,112,113)

解决方案 »

  1.   

    select 1 from table where alive=1  and id in(111,112,113)如果返回1 说明在,如果返回为空 则表示在
      

  2.   

    哦 理解有偏差! 对不起 :)if exists(select 1 from table1 where alive=1  and  id=111) and 
       exists(select 1 from table1 where alive=1  and  id=112) and 
       exists(select 1 from table1 where alive=1  and id=113)
       print '包含'
    else
       print '不包含'
      

  3.   

    如果用上面的,效率不高,可看看这样:
    集合的包含关系,用另为个辅助表。
    declare @t1 table (a int)  --被包含的集合
    insert @t1
    select 111 union 
    select 112 union 
    select 113
    --id 列必须为 int 类型
    if exists(select 1 from @t1 where checksum(*) not in(select checksum(*) 
       from (select id from table1 where alive=1)t ))
       print '包含'
    else
       print '不包含'