当前位置:网站首页>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
边栏推荐
- Learning Weekly - total issue 63 - an open source local code snippet management tool
- [deep learning] overview | the latest progress of deep learning
- 对称式加密与非对称式加密的对比
- Redis的十大常见应用场景
- JMeter test plan cannot be saved solution
- Troubleshooting error: NPM install emojis list failed
- How to avoid duplicate data when the database is high and distributed
- [STL]list模拟实现
- 『每日一问』volatile干嘛的
- 学习周刊-总第 63 期-一款开源的本地代码片段管理工具
猜你喜欢

Nacos搭建配置中心出现client error: invalid param. endpoint is blank

Activemq-- delayed delivery and scheduled delivery

What version of Oracle10g single instance database is better to upgrade to? Ask for suggestions
![[arm] Xintang nuc977 transplants wk2124 drive](/img/0c/fa21d7a44e0263dde4d3135a78818f.png)
[arm] Xintang nuc977 transplants wk2124 drive

Leetcode组合总和+剪枝

Composition of the interview must ask items

Shell script

实现简单的RESTful API服务器
![[BUUCTF-n1book][第二章 web进阶]SSRF Training](/img/29/8894d04b27e0e73c4458c27bd9b935.png)
[BUUCTF-n1book][第二章 web进阶]SSRF Training

activemq--死信队列
随机推荐
Full solution of JDBC API
无法再web服务器上启动调试,web服务器未能找到请求资源
动态添加多tab,并初始化每个tab页面
office文件对应的Content-Type类型
Redis sentry, master-slave deployment details
对称式加密与非对称式加密的对比
ActiveMQ -- JDBC Journal of persistent mechanism
What are the commands used by pl/sql tools to export SQL files?
Six storage types in C language: Auto register static extern const volatile
2022-7-14 JMeter pressure test
『每日一问』volatile干嘛的
Write two channel (stereo) immediately Wav file
PHP date() function does not support processing numbers greater than 2147483648? "Suggested collection"
C#语言和SQL Server数据库技术
JDBC quick start
Uniapp intercepts route jumps through addinterceptor to control whether the page needs to log in
Learn about spark project on Nebula graph
将list集合的某一字段拼接单个String
activemq--消息重试机制
ActiveMQ -- JDBC code of persistent mechanism