当前位置:网站首页>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
边栏推荐
- 链表内指定区间反转
- [AUTOSAR II appl overview]
- Excel removes the data after the decimal point and rounds the number
- Machine learning terminology
- Key wizard play strange learning - multithreaded background coordinate recognition
- R language uses coin package to apply permutation tests to independence problems (permutation tests, whether response variables are independent of groups, are two numerical variables independent, and
- [AUTOSAR nine c/s principle Architecture]
- Leetcode-1964: find the longest effective obstacle race route to each position
- MySQL basic usage 02
- The arm core board / development board of Feiling equipped with Ti am62x made its debut in embedded world 2022
猜你喜欢
![leetcode:701. Insertion in binary search tree [BST insertion]](/img/bc/1dda73198488eb81b49be2c1dff6c2.png)
leetcode:701. Insertion in binary search tree [BST insertion]

Infrared thermography temperature detection system based on arm rk3568

FPGA - 7 Series FPGA internal structure clocking -04- multi area clock

MySQL basic usage 02

瑞萨RZ/G2L ARM开发板存储读写速度与网络实测

有向图的强连通分量

What is needed to develop a domestic arm intelligent edge computing gateway

【FH-GFSK】FH-GFSK信号分析与盲解调研究

How wide does the dual inline for bread board need?
![[C language] branch and loop statements (Part 1)](/img/47/6efcc59bd26e26f66c698635c26c8b.png)
[C language] branch and loop statements (Part 1)
随机推荐
Infrared thermography temperature detection system based on arm rk3568
Leetcode-871: minimum refueling times
Leetcode-2115: find all the dishes that can be made from the given raw materials
信息熵的基础
[introduction to AUTOSAR seven tool chain]
[AUTOSAR eight OS]
mysql 多表联合删除
[AUTOSAR I overview]
R language ggplot2 visualization: use ggplot2 to display dataframe data that are all classified variables in the form of thermal diagram, and customize the legend color legend of factor
[自我管理]时间、精力与习惯管理
Draw love with go+ to express love to her beloved
【FH-GFSK】FH-GFSK信号分析与盲解调研究
Key wizard play strange learning - front desk and Intranet send background verification code
【C语言】分支和循环语句(上)
【FPGA教程案例6】基于vivado核的双口RAM设计与实现
异步、郵件、定時三大任務
Test shift right: Elk practice of online quality monitoring
MongoDB系列之MongoDB常用命令
1696C. Fishingprince plays with array [thinking questions + intermediate state + optimized storage]
[case sharing] let the development of education in the new era advance with "number"