select top 16 * from picUploadT where picType='baobaoXiu' and userid in (1,2,3) order by picId desc 这样是不要运行的select top 16 * from picUploadT where picType='baobaoXiu' and userid exists (1,2,3) order by picId desc 就提示错误。
请问:错在哪里?谢谢

解决方案 »

  1.   

    EXISTS
    指定一个子查询,检测行的存在,没 这样用的
      

  2.   

    exists 后面是是一个受限的 SELECT 语句 (不允许有 COMPUTE 子句和 INTO 关键字)。
      

  3.   

    declare @t table(id int)
    insert into @t select 1 union select 2 union select 3 union select 4select *
    from @t
    where id =any (select 1 union select 2)
    /*id          
    ----------- 
    1
    2*/嘿嘿
      

  4.   

    select top 16 * from picUploadT where picType='baobaoXiu' and userid exists (1,2,3) order by picId desc
    userid exists (1,2,3) 这里不对
    exists 和 in不是一个概念