当前位置:网站首页>19、 MySQL -- SQL statements and queries
19、 MySQL -- SQL statements and queries
2022-07-03 20:22:00 【Seven peanuts】
SQL Structured query statements (Structure Query Language) Include DDL Data definition language (Data Definition Language)、DML Data operation language (Data Manipulation Language) and DCL Data control language (Data Control Language).
DDL Include create、frop、alter、truncate sentence
DML Including increase insert Delete delete truncate Change replace updata check select
DCL Include grant revoke
This article discusses SELECT Statement and write SQL Notes on sentences
1.select sentence
select @@autoincrement Find variables
SELECT *|{[DISTINCT] column|select_expr [alias], ...]} [FROM [database.]table]
{} Braces indicate that the content inside must be written with
[] Brackets indicate that the contents inside are optional
| One out of two
, … It means that the previous content can be repeated several
Lowercase letters indicate that the actual name should be used here
* Represents any field
DISTINCT Indicates that the result of the query is de duplicated
[alias] Alias
# Query all fields
# Use the alias
2.where Clause
where condition Need to cooperate with select Statements use condition On condition that , Also known as filter condition
# Can't be in WHERE Use column aliases in Clause
3.order by Clause
[ORDER BY {column, expr, numeric_position} [ASC|DESC]];
Need and select Statements use ASC Ascending ,DESC Descending , Default ascending order 、
4. Group functions
Group function is also called aggregate function , It operates on a collection of rows , Give a result for each group
Common group functions
AVG([DISTINCT] expr) : averaging
COUNT({*|[DISTINCT] } expr) : Count the number of lines
MAX([DISTINCT] expr) : For maximum
MIN([DISTINCT] expr) : For the minimum
SUM([DISTINCT] expr) : Sum up
# Nested use is not allowed between group functions , It can be a function expression , Multiple aggregate functions can appear
GROUP_CONCAT() function
5.HAVING Clause
[HAVING where_condition] It is specially used to filter the grouped results
HAVING Group functions can be used in Clauses ,where Cannot be used with group functions
6. Multi table join query
SELECT paymentno, pen.playerno, amount,NAME
FROM penalties pen, players p
WHERE pen.playerno = p.playerno;
7. Subquery
边栏推荐
- Teach you how to quickly recover data by deleting recycle bin files by mistake
- Initialization and instantiation
- Plan for the first half of 2022 -- pass the PMP Exam
- Microservice knowledge sorting - search technology and automatic deployment technology
- The global industrial design revenue in 2021 was about $44360 million, and it is expected to reach $62720 million in 2028. From 2022 to 2028, the CAGR was 5.5%
- Example of peanut shell inner net penetration
- Phpexcel import export
- Global and Chinese market of high purity copper foil 2022-2028: Research Report on technology, participants, trends, market size and share
- Battle drag method 1: moderately optimistic, build self-confidence (1)
- 6. Data agent object Defineproperty method
猜你喜欢
The global industrial design revenue in 2021 was about $44360 million, and it is expected to reach $62720 million in 2028. From 2022 to 2028, the CAGR was 5.5%
Nerfplusplus parameter format sorting
Battle drag method 1: moderately optimistic, build self-confidence (1)
Upgrade PIP and install Libraries
An old programmer gave it to college students
In 2021, the global revenue of syphilis rapid detection kits was about US $608.1 million, and it is expected to reach US $712.9 million in 2028
Today's work summary and plan: February 14, 2022
Oak-d raspberry pie cloud project [with detailed code]
Based on laravel 5.5\5.6\5 X solution to the failure of installing laravel ide helper
Test panghu was teaching you how to use the technical code to flirt with girls online on Valentine's Day 520
随机推荐
Get log4net log file in C - get log4net log file in C
Battle drag method 1: moderately optimistic, build self-confidence (1)
Nacos usage of micro services
47. Process lock & process pool & Collaboration
4. Data binding
Gym welcomes the first complete environmental document, which makes it easier to get started with intensive learning!
Shortest path problem of graph theory (acwing template)
Basic knowledge of dictionaries and collections
Use of CMD command
App compliance
Task of gradle learning
5. MVVM model
In 2021, the global revenue of syphilis rapid detection kits was about US $608.1 million, and it is expected to reach US $712.9 million in 2028
Analysis of gas fee setting under eip1559
Fingerprint password lock based on Hal Library
2.1 use of variables
4. Data splitting of Flink real-time project
Recommendation of books related to strong foundation program mathematics
The 15 year old interviewer will teach you four unique skills that you must pass the interview
【leetcode】1027. Longest arithmetic sequence (dynamic programming)