当前位置:网站首页>Database SQL language 02 connection query
Database SQL language 02 connection query
2022-07-03 01:12:00 【Super brother 1986】
JOIN


Example :
/* Link query If you need data from multiple data tables to query , Multiple queries can be implemented through join operators Internal connection inner join Query the intersection of the result sets in two tables External connection outer join The left outer join left join ( Take the left table as a benchmark , The table on the right matches one by one , It doesn't match , Return the record in the left table , The table on the right shows NULL fill ) Right connection right join ( Take the right table as a benchmark , The table on the left matches one by one , It doesn't match , Return the record in the right table , On the left side of the table NULL fill ) Equivalent connection and non equivalent connection Self join */
-- Query the information of the students who took the exam ( Student number , The student's name , Account No , fraction )
SELECT * FROM student;
SELECT * FROM result;
/* Ideas : (1): Analyze requirements , Make sure that the columns of the query come from two classes ,student result, Link query (2): Determine which connection query to use ?( Internal connection ) */
SELECT s.studentno,studentname,subjectno,StudentResult
FROM student s
INNER JOIN result r
ON r.studentno = s.studentno
-- The right connection ( Can also be realized )
SELECT s.studentno,studentname,subjectno,StudentResult
FROM student s
RIGHT JOIN result r
ON r.studentno = s.studentno
-- Equivalent connection
SELECT s.studentno,studentname,subjectno,StudentResult
FROM student s , result r
WHERE r.studentno = s.studentno
-- Left connection ( I checked all the students , Those who don't take exams will find out )
SELECT s.studentno,studentname,subjectno,StudentResult
FROM student s
LEFT JOIN result r
ON r.studentno = s.studentno
-- Check out the absent students ( Left link application scenario )
SELECT s.studentno,studentname,subjectno,StudentResult
FROM student s
LEFT JOIN result r
ON r.studentno = s.studentno
WHERE StudentResult IS NULL
-- Thinking questions : Query the information of the students who took the exam ( Student number , The student's name , Subject name , fraction )
SELECT s.studentno,studentname,subjectname,StudentResult
FROM student s
INNER JOIN result r
ON r.studentno = s.studentno
INNER JOIN `subject` sub
ON sub.subjectno = r.subjectno
边栏推荐
- 机器学习术语
- Kivy教程大全之如何在 Kivy 中创建下拉列表
- Data analysis, thinking, law breaking and professional knowledge -- analysis method (I)
- 飞凌搭载TI AM62x的ARM核心板/开发板首发上市,亮相Embedded World 2022
- 【爱死机】《吉巴罗》被忽略的细节
- Key wizard play strange learning - front desk and Intranet send background verification code
- 12_微信小程序之微信视频号滚动自动播放视频效果实现
- R language generalized linear model function GLM, (model fit and expression diagnostics), model adequacy evaluation method, use plot function and car package function
- matlab 多普勒效应产生振动信号和处理
- 【无标题】
猜你喜欢
![[overview of AUTOSAR three RTE]](/img/6a/0df33beb42f165af77a17b5d8b01e2.png)
[overview of AUTOSAR three RTE]

(C语言)数据的存储
![[overview of AUTOSAR four BSW]](/img/19/c2273bbedb7f8d859e5a3805ed5740.png)
[overview of AUTOSAR four BSW]

MySQL basic usage 02

数学建模之线性规划(含MATLAB代码)

ROS2之ESP32简单速度消息测试(极限频率)
![leetcode:701. Insertion in binary search tree [BST insertion]](/img/bc/1dda73198488eb81b49be2c1dff6c2.png)
leetcode:701. Insertion in binary search tree [BST insertion]

Daily topic: movement of haystack

信息熵的基础

Matlab saves the digital matrix as geospatial data, and the display subscript index must be of positive integer type or logical type. Solve the problem
随机推荐
excel去除小数点后面的数据,将数字取整
删除有序链表中重复的元素-II
Matlab saves the digital matrix as geospatial data, and the display subscript index must be of positive integer type or logical type. Solve the problem
Specified interval inversion in the linked list
Basic concept and implementation of overcoming hash
Basic remote connection tool xshell
Draw love with go+ to express love to her beloved
Linear programming of mathematical modeling (including Matlab code)
[untitled]
excel表格计算时间日期的差值,并转化为分钟数
mysql 多表联合删除
Machine learning terminology
Daily topic: movement of haystack
MongoDB系列之MongoDB常用命令
Merge K sorted linked lists
tail -f 、tail -F、tailf的区别
Leetcode-2115: find all the dishes that can be made from the given raw materials
FPGA - 7 Series FPGA internal structure clocking -04- multi area clock
[AUTOSAR eight OS]
[overview of AUTOSAR three RTE]