当前位置:网站首页>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

边栏推荐
- Microservice framework - frequently asked questions
- Node MySQL serialize cannot rollback transactions
- 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%
- First knowledge of database
- Global and Chinese market of micro positioning technology 2022-2028: Research Report on technology, participants, trends, market size and share
- The 15 year old interviewer will teach you four unique skills that you must pass the interview
- Bool blind note - score query
- Global and Chinese market of two in one notebook computers 2022-2028: Research Report on technology, participants, trends, market size and share
- jvm jni 及 pvm pybind11 大批量数据传输及优化
- FPGA 学习笔记:Vivado 2019.1 工程创建
猜你喜欢

2.1 use of variables

In 2021, the global foam protection packaging revenue was about $5286.7 million, and it is expected to reach $6615 million in 2028

1.4 learn more about functions

2.2 integer

1.5 learn to find mistakes first

2.6 formula calculation

LabVIEW training

Don't be afraid of no foundation. Zero foundation doesn't need any technology to reinstall the computer system

Typora charges, WTF? Still need support
![Oak-d raspberry pie cloud project [with detailed code]](/img/34/76b461bf03fba373da5b5898c5204c.jpg)
Oak-d raspberry pie cloud project [with detailed code]
随机推荐
In 2021, the global revenue of thick film resistors was about $1537.3 million, and it is expected to reach $2118.7 million in 2028
About callback function and hook function
FPGA 学习笔记:Vivado 2019.1 工程创建
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%
The 29th day of force deduction (DP topic)
Global and Chinese market of high temperature Silver sintering paste 2022-2028: Research Report on technology, participants, trends, market size and share
1.4 learn more about functions
Professional interpretation | how to become an SQL developer
Global and Chinese markets for medical temperature sensors 2022-2028: Research Report on technology, participants, trends, market size and share
Qtablewidget control of QT
PR notes:
Rad+xray vulnerability scanning tool
Derivation of decision tree theory
2. Template syntax
3. Data binding
Upgrade PIP and install Libraries
[postgresql]postgresql custom function returns an instance of table type
Native table - scroll - merge function
Initialization and instantiation
Sightseeing - statistics of the number of shortest paths + state transfer + secondary small paths