内连接

关键字: inner join  on

语句:select * from <a_table> inner join <b_table> on a.id = b.id ;

说明:返回表之间关联字段相符的记录

Table:stuinfo

Table:stuscore

采用内连接查询方式:

select stuinfo.stuid,stu_name,gender,Math,English
from stuinfo inner join stuscore
on stuinfo.stuid = stuscore.stuid;

查询结果如下:

左连接

关键字:left join  on

语句:select * from <a_table> left join <b_table> on a.id = b.id ;

说明:左表a_table的记录将全部显示出来,右表只会显示符合条件的记录,右表记录不足的地方将显示Null。

采用左连接的查询方式:

select stuinfo.stuid,stu_name,gender,Math,English
from stuinfo left join stuscore
on stuinfo.stuid = stuscore.stuid;

查询结果如下:

右连接

关键字:right join  on

语句:select * from <a_table> right join <b_table> on a.id = b.id ;

说明:右表a_table的记录将全部显示出来,左表只会显示符合条件的记录,左表记录不足的地方将显示Null。

采用右连接的查询方式:

select stuscore.stuid,stu_name,gender,Math,English
from stuinfo right join stuscore
on stuinfo.stuid = stuscore.stuid;

查询结果如下:

2020-03-13 16:03

最新文章

  1. python编码声明的位置很重要
  2. SPOJ #440. The Turtle&#180;s Shortest Path
  3. 刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第五章 3(Sorting/Searching)
  4. 转:CFile::Seek
  5. linux 常用压缩工具快速指南
  6. PES包头
  7. 关于AJAX使用中出现中文乱码的问题
  8. java中遍历map的几种方法介绍
  9. ArrayList 和 LinkedList 源码分析
  10. windows server 2012 R2 部署AD域服务
  11. vi/vim tab键空格数修改
  12. vim选中多行缩进(python多行缩进)与删除多行前面的空格
  13. Apache Struts2高危漏洞(S2-057CVE-2018-11776)
  14. Python加密与解密
  15. P3420 [POI2005]SKA-Piggy Banks
  16. 【nginx】配置详解
  17. java基础-day8
  18. centos7系统下nginx安装并配置开机自启动操作
  19. Sql语句中两个比较迷糊的概念:“连接查询” 与 “外键约束”
  20. 聊一聊数组的map、reduce、foreach等方法

热门文章

  1. Java安装和配置
  2. .NET 5 Preview 1中的ASP.NET Core更新 (2020年3月16日)
  3. Spyder——科学的Python开发环境
  4. 【分布式锁】01-使用Redisson实现可重入分布式锁原理
  5. iview Checkbox 多选框 单个的时候 如果需要change 以后进行赋值 就要用value 不要用v-modal 然后用updateModel 方法
  6. 图解I/O模型
  7. Journal of Proteome Research | “Differential Visual Proteomics”: Enabling the Proteome-Wide Comparison of Protein Structures of Single-Cells(“差异视觉蛋白质组学”:实现单细胞中蛋白质结构的组学比较)(解读人:李思奇)
  8. Servlet(五)----ServletContext对象
  9. nop 配置阿里cdn 联通4g 页面显示不全 查看源代码发现被截断
  10. 微信小程序分享转发用法大全——自定义分享、全局分享、组合分享