select xx…… from a,b where xx=xx
select xx…… from a join b on xx=xx
今天做一个项目,突然发现这两句的结果是一样的,请问这两种查询方式有什么区别

解决方案 »

  1.   

    两个没区别内连接
    select xx…… from a,b where xx=xx
    select xx…… from a join b on xx=xx左连接
    select xx…… from a,b where a.xx=b.xx(+)
    select xx…… from a left join b on a.xx=b.xx右连接
    select xx…… from a,b where a.xx(+)=b.xx
    select xx…… from a right join b on a.xx=b.xx
      

  2.   

    表1 left join 表2 on 关联关系表  ------>表1有数据,表2相应字段为空时,可显示
    表1 join 表2 on 关联关系表       ------>2个表只要有相应字段为空的信息都不显示
    表1 right join 表2 on 关联关系表 ------>表2有数据,表1相应字段为空时,可显示
      

  3.   


    为空的字段可以用nvl()来判断 优化查询结果
      例如:
        select i1.nid,i1.name,nvl(i2.address,'中国') from info i1 join info2 i2 on i1.nid=i2.nid
      判断地址为空时,添入一个大范围的地址。
      

  4.   

    一个是89年的sql标准,一个是92年的sql标准,实际没什么区别