请问以下三语句的区别 谢谢! 回复都有分啊 
select a,b from tb1 ,tb2 where tb1.no=tb2.noselect a,b from tb1 join tb2 on tb1.no=tb2.noselect a,b from tb1 where  exists(select * from tb2 where tb1.no=tb2.no)

解决方案 »

  1.   

    语句1为直连 结果为t1和t2表中关联出都存在结果
    语句2为外联 但是好像没有直接就写个join的 应该指定连接方式 left join,right join,full join 
    语句3为条件查询 效率低 结果为t1和t2表中关联出都存在结果
      

  2.   

    以上三种关联都是等连接,无法从方法上比较。
    可以比较的只能说是执行效率。
    //此语句执行效率最高
    select a,b from tb1 where exists(select * from tb2 where tb1.no=tb2.no)
    //此语句执行效率第二
    select a,b from tb1 join tb2 on tb1.no=tb2.no
    //执行效率第三
    select a,b from tb1 ,tb2 where tb1.no=tb2.no
    我用公司的表进行了关联总共有 135018 条数据执行效率如下
    exists 为 0.011S
    join   为 0.047S
    等连接  为 0.062S