select * from A where A.x not in(select B.x from B where B.z<>A.z and B.y=35161)
由于A、B表都很大,因此使用in和子查询要很长时间才能出结果,请问能不能改写这sql语句,采用联合查询来查呢?谢谢!

解决方案 »

  1.   

    可以先试一下select a.*
    from a left join b on (a.x=b.x and B.z<>A.z and B.y=35161)
    where b.x is null
      

  2.   

    这个sql语句确实能达到相同的效果,但我不明白的是后面为什么要加上b.x is null!
      

  3.   

    这个我明白了,谢谢!分数见者有份,分给guyzyl 5分,没意见吧?
      

  4.   

    这你需要了解一下左外连接。 left join