--这句是分页代码,如何转换成 not existsselect top 3 Code,Name,Age,Sex from B where Code not in(select top 3 Code from B)以前从没用过 exists

解决方案 »

  1.   

    select top 3 Code,Name,Age,Sex from B T1
    where Code not EXISTS(SELECT * FROM (select top 3 Code from B) T2 WHERE T2.CODE=T1.CODE) 
      

  2.   


    比 not in 复杂啊
      

  3.   

    select top 3 Code,Name,Age,Sex from B as BB
    where not exists
      (select * from B where code <> BB.code)
      

  4.   


    关键字 'EXISTS' 附近有语法错误。
      

  5.   

    select top 3 Code,Name,Age,Sex from B T1
    where Code not EXISTS(SELECT * FROM (select top 3 Code from B) T2 WHERE T2.CODE=T1.CODE) 多了个
      

  6.   

    select top 3 Code,Name,Age,Sex from B T1 where   not EXISTS(SELECT * FROM (select top 3 Code from B) T2 WHERE T2.CODE=T1.CODE)
      

  7.   

    select top 3 Code,Name,Age,Sex from B where Code not in(select top 3 Code from B AND CODE IS NOT NULL) 
      

  8.   


    恩但是 not in 复杂
      

  9.   

    select 
      top 3 Code,Name,Age,Sex 
    from 
      B b
    where 
      not exists(select 1 from (select top 3 Code from B) a WHERE a.code=b.code) 
      

  10.   

    加了个IS NOT NULL,可以查出数据,看你的原因
      

  11.   

    我用 not exists 和 not in 进行 分100w条数据,速度上没多大区别啊,几乎一样。他们说 not in 会使索引无效!
      

  12.   

    执行时间:
    用 not in 是 288 毫秒
    用 not exists 是 283 毫秒
      

  13.   

    not in
    可以用到索引吧
      

  14.   


    NOT IN不能用到索引哦,晕
      

  15.   

    我查 90w 条以后的数据 依然很快啊那用 not exists 就能用到索引?
      

  16.   

    [标准SQl Code] select top 3 Code,Name,Age,Sex from B T1
    where Code not EXISTS(SELECT Code,Name,Age,Sex FROM (select top 3 Code from B) T2 WHERE T2.CODE=T1.CODE)