A表: 
ID  STATUS NAME
001  GOOD  jk
002  BAD   DK
NULL  GOOD  sd    
........  不要使用in,exists,我的数据量太大,in,exists效率很低。
怎么根据ID好,找出STATUS相同的行?????
例如 当ID=001,得出  
001  GOOD  jk
NULL  GOOD  sd    

解决方案 »

  1.   

    exists 应该不慢了。 检查你的表中索引情况。
      

  2.   

    exists效率不会太慢了。关键表中索引是怎样。
      

  3.   

    貌似没明白
    status 相同的行如果说 还有001 GOOD jk
    002 BAD DK
    NULL GOOD sd   
    004  linux ls
    005  linux ie是不是你要的是重复列呢?
      

  4.   

    在ID STATUS 上建立索引没有
      

  5.   


    select * from A a 
    left join 
    (select status from A where ID = '001')b on a.status = b.status
    where b.status is not null;
      

  6.   


    select a.* from A a left join (select status from A where ID = '001')b on a.status = b.status where b.status is not null; 
      

  7.   


    select a.* from A a 
    left join 
    (select distinct status from A where ID = '001')b on a.status = b.status
    where b.status is not null;