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

边栏推荐
- Point cloud data denoising
- 2.3 other data types
- Use of CMD command
- Node MySQL serialize cannot rollback transactions
- How to handle wechat circle of friends marketing activities and share production and release skills
- Network security Kali penetration learning how to get started with web penetration how to scan based on nmap
- Derivation of decision tree theory
- The simplicity of laravel
- Parental delegation mechanism
- 强基计划 数学相关书籍 推荐
猜你喜欢

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%

JMeter connection database

Example of peanut shell inner net penetration

Virtual machine installation deepin system

Preliminary practice of niuke.com (11)

IP address is such an important knowledge that it's useless to listen to a younger student?

Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of rotary tablet presses in the global market in 2022

Based on laravel 5.5\5.6\5 X solution to the failure of installing laravel ide helper

Gym welcomes the first complete environmental document, which makes it easier to get started with intensive learning!

Commands related to files and directories
随机推荐
[effective Objective-C] - block and grand central distribution
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
Global and Chinese markets of lithium chloride 2022-2028: Research Report on technology, participants, trends, market size and share
Qtablewidget control of QT
Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of rotary tablet presses in the global market in 2022
Cesiumjs 2022 ^ source code interpretation [7] - Analysis of the request and loading process of 3dfiles
6. Data agent object Defineproperty method
Global and Chinese market of liquid antifreeze 2022-2028: Research Report on technology, participants, trends, market size and share
2.1 use of variables
Task of gradle learning
Instructions for common methods of regular expressions
Q&A:Transformer, Bert, ELMO, GPT, VIT
How to handle wechat circle of friends marketing activities and share production and release skills
Initialization and instantiation
3. Data binding
Print linked list from end to end
Don't be afraid of no foundation. Zero foundation doesn't need any technology to reinstall the computer system
Ruby replaces gem Alibaba image
44. Concurrent programming theory
Recommendation of books related to strong foundation program mathematics