当前位置:网站首页>Multi table (Association) query of SQL query data
Multi table (Association) query of SQL query data
2022-07-29 02:59:00 【m0_ sixty-seven million four hundred and three thousand one hun】
Data sheet :




Association queries are mainly divided into :(inner join) Cross correlation 、(left join) Left Association 、(right join) On the right
(inner join) Cross correlation :
- Definition :(inner join) Cross association only returns rows with equal fields in two tables
- grammar :select * from surface 1
inner join surface 2
on surface 1. Field number = surface 2. Field number
For example, I want to check the cross correlation between student table and grade table , First of all, find the fields with equal connection

The only field they share is the student number
Then write it according to the above grammar :


- Look for the , Output table is only 5 Information of students , But our student list is shared 10 Of a student , Its definition is to return only rows with equal fields in two tables ,
There are only 5 Student number of students , Relative to the student table, the only connection can be 5 Student information

(left join) Left Association :
- Definition :(left join) The left Association returns all records in the left table and records with the same join fields in the right table
- grammar :select * from surface 1
left join surface 2
on surface 1. Field number = surface 2. Field number

Then check the left correlation between the student table and the grade sheet. First type it with reference to the grammar , The effect is as follows :


Left association is based on the left table , The data in the right table shows , No data shows null
(right join) On the right :
- Definition :(right join) Right association returns all records in the right table and records with the same join fields in the left table
- grammar :select * from surface 1
right join surface 2
on surface 1. Field number = surface 2. Field number
Right association is just opposite to left Association



边栏推荐
猜你喜欢

【FreeSwitch开发实践】media bug获取通话语音流

MySQL - count(字段)、count(主键)、count(1)、count(*)的区别

并发模式之异步回调Future模式

向DataFrame中的特定位置添加一行

04 | 后台登录:基于账号密码的登录方式(上)

Jinshan cloud returns to Hong Kong for listing: Hong Kong stock rush of Chinese to B cloud manufacturers

解读AI机器人养宠引领时尚潮流

R language error: compilation failed for package '****‘

架构师进阶,微服务设计与治理的 16 条常用原则

STP协议(生成树协议)
随机推荐
Day 10 notes
Flink kernel source code (VII) Flink SQL submission process
Mysql复合查询(重要)
HTB-Blocky
centos安装mysql8
Chapter 09_ Use of performance analysis tools
Day 8 notes
Pgzero飞机大战
多线程实现多用例文件并发读取执行+Selenium Grid4实现测试框架分布式部署
HTB-Blue
UE4.25 Slate源码解读
R language error: compilation failed for package '****‘
New UI Sifang aggregate payment system source code / new usdt withdrawal / latest update security upgrade to fix XSS vulnerability patch vulnerability
Look at robot education and lead the mainstream of quality education
看机器人教育引领素质教育主流
会议OA项目之我的审批功能
C language: Little Lele and Euclid
MySQL 操作数据库数据报错:Fatal error encountered during command execution
Implementation principle of golang synergy
FTP协议详解