zoukankan      html  css  js  c++  java
  • MySQL 关联查询  外连接 { LEFT| RIGHT } JOIN

    左外连接: (以左表为基准)
    两张表做连接的时候,在连接条件不匹配的时候
    留下左表中的数据,而右表中的数据以NULL填充
    例:使用左连接把学生的数据全取出来,该学生没有学院信息的用NULL填充

    mysql>  select * from  student  left join  department
             ->  on dept_id= d_id;


    右外连接: (以右表为基准)
    对两张表做连接的时候,在连接条件不匹配的时候
    留下右表中的数据,而左表中的数据以NULL填充
    例:使用右外连接,把没有的学院的数据也显示出来
    insert into department(d_name)  value('艺术学院’);

    mysql>   select * from  student right join department
             ->   on dept_id= d_id;

  • 相关阅读:
    对坐标点的离散化
    线段树-离散化处理点
    树状数组
    线段树
    dfs
    vector
    go 参数传递的是值还是引用 (转)
    go 数组指针 指针数组
    go 协程
    go 接口实现
  • 原文地址:https://www.cnblogs.com/mariobear/p/9180542.html
Copyright © 2011-2022 走看看