当前位置:网站首页>Mysql database easy learning 09 - commonly used by data analysts: multi table query of data query language DQL
Mysql database easy learning 09 - commonly used by data analysts: multi table query of data query language DQL
2022-06-22 01:58:00 【Smart Aries】
1 The relationship between tables
1.1 one-on-one

1.2 One to many

1.3 Many to many

2 How to connect
2.1 Transverse connection
2.1.1 Internal connection inner join
Connect two tables according to the connection conditions , Return the line that meets the condition 
select Field 1[,…] from surface 1[ inner] join surface 2 on Connection condition ;
2.1.2 Left connection left join
In addition to the lines that satisfy the join conditions, the result , It also includes all the rows of the left table 
select Field 1[,…] from surface 1 left join surface 2 on Connection condition ;
2.1.3 The right connection right join
In addition to the lines that satisfy the join conditions, the result , It also includes all the rows of the right table 
select Field 1[,…] from surface 1 right join surface 2 on Connection condition ;
2.1.4 The cartesian product cross join
Suppose the set A={a,b}, aggregate B={1,2,3}, Then the Cartesian product of two sets is {(a,1),(a,2),(a,3),(b,1),(b,2),(b,3)}
select Field 1[,…] from surface 1, surface 2[,…];
select Field 1[,…] from surface 1 cross join surface 2[,…];
Eliminate Cartesian product :
Line by line judgment , Equal leave , Unequal exclusion
select Field 1[,…] from surface 1, surface 2[,…] where filter ;
2.1.5 Self join
By setting the table alias , Virtualize the same table into multiple tables for connection
select * from tabel a inner join table b
on a.id = b.id
2.2 Longitudinal connection
2.2.1 Concept
Put more than one select The query results of the statement are combined into a result set
Of the merged result set Number of columns 、 Sequence and data type It has to be exactly the same
2.2.2 union duplicate removal :
#select Field 1[, Field 2,…] from Table name union select Field 1[, Field 2,…] from Table name ;
select * from t1 union select * from t2;
2.2.3 union all No weight removal :
#select Field 1[, Field 2,…] from Table name union all select Field 1[, Field 2,…] from Table name ;
select * from t1 union all select * from t2;
3 Connection condition
3.1 Equivalent connection
surface 1.id= surface 2.id
3.2 Unequal value connection
surface 1.id Compare surface 2.id
边栏推荐
- Individual problem solution of the 298th round of force deduction
- Localdatetime format time
- acwing 837. 连通块中点的数量 (并查集维护额外信息---集合数量)
- 【第 17 章 基于 Harris 的角点特征检测--Matlab机器学习项目实战】
- [bit operation] leetcode1009 Complement of Base 10 Integer
- Google multi user anti Association tool
- 【第 15 章 基于小波的图像压缩技术深度学习机器学习的图像处理应用matlab.】
- How to restore the IE browser auto jump edge
- Redis缓存异常及处理方案总结
- 英特尔发展史概述
猜你喜欢

MBA-day24 最值问题
![[number theory] leetcode1010 Pairs of Songs With Total Durations Divisible by 60](/img/cc/ca70945b1bb2f57093bbae721ca635.png)
[number theory] leetcode1010 Pairs of Songs With Total Durations Divisible by 60

GAMES-101-个人总结归纳-Transformation

【第 04 章 基于Hough变化的答题卡识别】
![[Chapter 13 image compression and reconstruction based on Hoffman -- image processing application of MATLAB deep learning practice]](/img/ac/6f3ce735f52bc44a5dd65e0f2b870c.png)
[Chapter 13 image compression and reconstruction based on Hoffman -- image processing application of MATLAB deep learning practice]
![Pytoch neural network [handwritten digit recognition]](/img/6b/fbb568e0f0d073ce5ba28f8b138a25.png)
Pytoch neural network [handwritten digit recognition]

第 18 章 基于GUI搭建通用视频处理工具matlab应用GUI实现

基于DPDK的高效包处理系统
![[chapter 02 weight adaptive image denoising technology based on Morphology - full system matlab intelligent driving in-depth learning]](/img/65/c9ba18ffd37f84c3ca399507625c90.png)
[chapter 02 weight adaptive image denoising technology based on Morphology - full system matlab intelligent driving in-depth learning]

Mba-day23 at most at least questions - exercises
随机推荐
2019 CSP-J1 CSP-S1 第1轮 初赛 答案解析及总结、视频等
Ansible Inventory 主机清单
[chapter 04 answer sheet recognition based on Hough change]
稳扎稳打学爬虫08—Selenium的使用方法详解
BSV上的委托合约(3)
Five years after graduation, I finally became a software testing engineer with a monthly salary of 13000
【第 17 章 基于 Harris 的角点特征检测--Matlab机器学习项目实战】
LeetCode 41 - 45 动态规划专题
测试apk-异常管控Sensor攻击者开发
【第 15 章 基于小波的图像压缩技术深度学习机器学习的图像处理应用matlab.】
Scuba China trip - Suzhou station, online and offline limited time registration channel has been opened!
初识Unity3D(项目结构、ProBuilder第三方插件)
Mysql数据库轻松学07—select语句书写顺序及执行顺序
shadertoy 实现简易指南针
NOIP初赛 CSP-J1 CSP-S1 第1轮 初赛 信奥中的数学知识(三)
【随笔】昨天研究了一天 RN 生态的 Expo 的确牛逼,从开发构建到部署一条龙,很好使。
抓包工具:Fiddler,软件测试工程师必备技能
Ansible 配置文件
Google Earth engine (GEE) - line chart of time series image combining VCI index and TCI temperature (Guatemala and El Salvador as examples)
Fabric.js IText 手动设置斜体