当前位置:网站首页>C language and SQL Server database technology
C language and SQL Server database technology
2022-07-25 09:22:00 【yushang_ zhang】
Join query and group query
One 、 Use Group By Grouping
1. The essence of grouping is classification , Then merge the same items
2. Grouping is to enable the aggregation function in the next step to make statistics on data of different classifications
3. Check the boys , Data volume of girls
4. Query the number of books in each category
5. Be careful : Use grouped query statements , The data that can appear in the result column needs to meet one of the following conditions :
a、 Columns participating in grouping
b、 Columns that use aggregate functions
Two 、 Use having Statement filter grouping results
1. Query the number of books in each category , Then sort in descending order according to the number of books
2.order by Put it on group by Behind
3. Query the number of books in each category , Filter out the classified data with only one book
4.having Statement is used to filter the grouped results
5. The execution order of the three statements is :
where --》 group by --》 having
6. Query books whose author is not empty , What is the number of books corresponding to each category , And filter out the classified data with only one book
3、 ... and 、 Inner join query
1. To prevent data redundancy , Our data is usually stored in different tables according to categories
2. If you want to view the complete data , You need to query data from multiple tables to combine them into a complete query result
3. This requires the use of multi table associated query , The multi table associated query revolves around the associated columns ( Foreign keys ) On going
4. Relational query :
a、 Inner join inner join
b、 External connection outer join
5. Inner join query :
a、 Use inner join ... on ... keyword , among inner It can be omitted
b、 Inner join query is the most commonly used in join query
c、on What follows is the correspondence between the two tables connected , Connection conditions
d、 Only the data with corresponding relationship in both tables will be displayed
e、as It can not only be used to alias columns , You can also alias the table
f、 Table name .* Indicates that all columns of this table are displayed
g、 Can pass where The condition specifies the writing method of implicit inner connection
h、 The order of the tables in the inline connection only indicates which table initiates the query , It does not affect the number of rows in the query result , That is, two tables are equal
i、 You can connect multiple tables at one time , For example, student table 、 Chart of subjects 、 Joint query of the third form of the transcript
Four 、 External connection query
1. Inner join query two tables are equal , Only data that meets the connection conditions can be displayed
2. The query method opposite to inner join is called outer join query , It can be used to filter records that do not meet the connection conditions
3. Syntax of external connection query :
left outer join ... on ...
right outer join ... on ...4. Features of external connection query :
a、 The tables participating in the connection in the external connection query can be divided into master and slave
b、 Match the data columns of the slave table with each row of the master table
c、 The qualified data is directly returned to the result set
d、 Unqualified records are filled in null Still return to the result set
e、 Whether the records of the main table match in the sub table , Can be guaranteed to appear in the query results
f、 The left table is the main table and becomes the left outer connection , The right table with the main table becomes the right outer connection
4. Query the book classification information without a book record
边栏推荐
- 『每日一问』LockSupport怎么实现线程等待、唤醒
- ActiveMQ -- leveldb of persistence mechanism
- activemq--可持久化机制之AMQ
- leetcode-238.除自身以外数组的乘积
- ActiveMQ -- dead letter queue
- Labview--- signal generator
- 实现简单的RESTful API服务器
- [stl]list Simulation Implementation
- Dark horse programmer JDBC
- The annualization of financial products is 4%. How much profit can you get from buying 10000 yuan a month?
猜你喜欢

分布式一致性协议之Raft

Query efficiency increased by 10 times! Three optimization schemes to help you solve the deep paging problem of MySQL

Sort out Huawei ap-3010dn_ V2 configuration create WiFi

How to write the code of wechat applet implementation tab

Uniapp intercepts route jumps through addinterceptor to control whether the page needs to log in

Network principle (2) -- network development

将list集合的某一字段拼接单个String

redis的五种数据结构原理分析

activemq--死信队列
![[arm] Xintang nuc977 transplants wk2124 drive](/img/0c/fa21d7a44e0263dde4d3135a78818f.png)
[arm] Xintang nuc977 transplants wk2124 drive
随机推荐
redis的五种数据结构原理分析
无法再web服务器上启动调试,web服务器未能找到请求资源
activemq--可持久化机制之JDBC的journal
Software examination system architecture designer concise tutorial | software life cycle
OpenCV实现简单的人脸追踪
activemq--可持久化机制之JDBC代码
Opencv realizes simple face tracking
Guangzhou has carried out in-depth "100 day action" to check the safety of self built commercial houses, and more than 2 million houses have been checked in two months
Dark horse programmer JDBC
API健康状态自检
SSM高级整合
C#语言和SQL Server数据库技术
[machine learning] Finally, the important steps of machine learning modeling have been clarified
OverTheWire-Bandit
Uniapp intercepts route jumps through addinterceptor to control whether the page needs to log in
Leetcode组合总和+剪枝
【线程知识点】-- 自旋锁
使用nexus3发布yum私服(离线-内网)
一文搞懂为什么要同时重写equals方法和hashCode方法+实例分析
Notes on in-depth analysis of C language 1