左连接 问题 请教

解决方案 »

  1.   

    select   *   from   a,b   where   a.id   =   b.id   (内联接) 
    select   *   from   a,b   where   a.id   =   b.id(+)   (左连接) 
    select   *   from   a,b   where   a.id(+)   =   b.id   (右连接) 
    select   *   from   a,b   where   a.id(+)   =   b.id(+)   (全连结)原贴地址:http://topic.csdn.net/u/20071210/12/8b05fe9a-a8c0-4279-9876-f3bf28a4da31.html
      

  2.   

    左连接:
    简单的说,就是将写在左边的表中的符合条件的数据行全部选出来(而不管是不是能与右边表的数据行匹配),而写在右边的表的数据行,就只选出能匹配条件的数据行举个例子:表A结构数据如下:id    name
    1     bbb
    2     ccc
    3     ddd表B结构数据如下:id    name   age
    1     eee    12
    2     ccc    13执行左外连接:select * from a,b where a.id=b.id(+)或者
    select * from a left join b on a.id=b.id或者
    select id,a.name,b.name,b.age from a left join b using (id)其结果都会是(前两条SQL语句):
    a.id   a.name    b.id    b.name    b.age
    1      bbb        1        eee      12
    2      ccc        2        ccc      13
    3      ddd        null     null     null
    而第三条SQL语句的结果是:id    a.name    b.name    b.age
    1      bbb       1         12
    2      ccc       2         13
    3      null      null      null相信看到这里,你应该明白左外连接是怎么回事了.
      

  3.   

    http://blog.csdn.net/gtlions/archive/2007/12/11/1930422.aspx
      

  4.   

    http://blog.csdn.net/gtlions/archive/2007/12/11/1930422.aspx
      

  5.   

    select * from A left outer join B on A.iD =B.ID