如下:not exists不是两结果集相减吗,为什么查不出任何结果??select top 10 id,name from kkk where not exists (select top 5 id,name from kkk)如果改为 exists 不是结果集相交吗,为什么结果集是第一个语句的结果集??
select top 10 id,name from kkk where exists (select top 5 id,name from kkk)我用的是2000

解决方案 »

  1.   

    select top 10 id,name from kkk where not exists (select top 5 id,name from kkk)语句的意思是,如果 exists后面的子句有结果集的话,则取出表的前10条记录;没有记录的话,则不取
      

  2.   

    不好意思,刚好说反了,上面的语句应去掉not
      

  3.   

    相当于
    if exists (select top 5 id,name from kkk)
    select top 10 id,name from kkk