zoukankan      html  css  js  c++  java
  • 数据库的左右外连接

      a表     id   name     b表     id   job   parent_id   
                  1   张3                   1     23     1   
                  2   李四                 2     34     2   
                  3   王武                 3     34     4       
      a.id同parent_id   存在关系   
    --------------------------------------------------    
     1) 内连接   
      select   a.*,b.*   from   a   inner   join   b     on   a.id=b.parent_id       
      结果是     
      1   张3                   1     23     1   
      2   李四                  2     34     2   

      2)左连接   
      select   a.*,b.*   from   a   left   join   b     on   a.id=b.parent_id       
      结果是     
      1   张3                   1     23     1   
      2   李四                  2     34     2   
      3   王武                  null   

     3) 右连接   
      select   a.*,b.*   from   a   right   join   b     on   a.id=b.parent_id       
      结果是     
      1   张3                   1     23     1   
      2   李四                  2     34     2   
      null                       3     34     4   

     4) 完全连接   
      select   a.*,b.*   from   a   full   join   b     on   a.id=b.parent_id   
      结果是     
      1   张3                  1     23     1   
      2   李四                 2     34     2   
      null                   3     34     4   
      3   王武                 null

  • 相关阅读:
    Ubuntu 装JDK
    U盘文件夹被病毒隐藏,且不能取消解决办法
    wireshark: there are no interfaces on which a capture can be done
    [转]Ubuntu 常用快捷键10个
    恢复被win7覆盖的Ubuntu Grub
    U盘安装Win7 64位
    荣耀3X畅玩版狙击红米note!
    Secret and Whisper
    360 chrome不能登录Google账户
    周鸿祎仍想做手机
  • 原文地址:https://www.cnblogs.com/superAnny/p/7595527.html
Copyright © 2011-2022 走看看