MySQL学习之路6-数据表连接方式
2024-10-09 00:39:47
内连接
关键字: 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
最新文章
- python编码声明的位置很重要
- SPOJ #440. The Turtle&#180;s Shortest Path
- 刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第五章 3(Sorting/Searching)
- 转:CFile::Seek
- linux 常用压缩工具快速指南
- PES包头
- 关于AJAX使用中出现中文乱码的问题
- java中遍历map的几种方法介绍
- ArrayList 和 LinkedList 源码分析
- windows server 2012 R2 部署AD域服务
- vi/vim tab键空格数修改
- vim选中多行缩进(python多行缩进)与删除多行前面的空格
- Apache Struts2高危漏洞(S2-057CVE-2018-11776)
- Python加密与解密
- P3420 [POI2005]SKA-Piggy Banks
- 【nginx】配置详解
- java基础-day8
- centos7系统下nginx安装并配置开机自启动操作
- Sql语句中两个比较迷糊的概念:“连接查询” 与 “外键约束”
- 聊一聊数组的map、reduce、foreach等方法
热门文章
- Java安装和配置
- .NET 5 Preview 1中的ASP.NET Core更新 (2020年3月16日)
- Spyder——科学的Python开发环境
- 【分布式锁】01-使用Redisson实现可重入分布式锁原理
- iview Checkbox 多选框 单个的时候 如果需要change 以后进行赋值 就要用value 不要用v-modal 然后用updateModel 方法
- 图解I/O模型
- Journal of Proteome Research | “Differential Visual Proteomics”: Enabling the Proteome-Wide Comparison of Protein Structures of Single-Cells(“差异视觉蛋白质组学”:实现单细胞中蛋白质结构的组学比较)(解读人:李思奇)
- Servlet(五)----ServletContext对象
- nop 配置阿里cdn 联通4g 页面显示不全 查看源代码发现被截断
- 微信小程序分享转发用法大全——自定义分享、全局分享、组合分享