当前位置:网站首页>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
边栏推荐
- 2.4 conversion of different data types
- How to check the permission to write to a directory or file- How do you check for permissions to write to a directory or file?
- Global and Chinese market of speed limiter 2022-2028: Research Report on technology, participants, trends, market size and share
- Use of CMD command
- Virtual machine installation deepin system
- Micro service knowledge sorting - asynchronous communication technology
- Rad+xray vulnerability scanning tool
- Global and Chinese markets of cast iron diaphragm valves 2022-2028: Research Report on technology, participants, trends, market size and share
- Nerfplusplus parameter format sorting
- Global and Chinese markets of active matrix LCD 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
Detailed and not wordy. Share the win10 tutorial of computer reinstallation system
Shortest path problem of graph theory (acwing template)
Cesiumjs 2022 ^ source code interpretation [7] - Analysis of the request and loading process of 3dfiles
Acquisition and transmission of parameters in automatic testing of JMeter interface
Test panghu was teaching you how to use the technical code to flirt with girls online on Valentine's Day 520
Introduction to golang garbage collection
Point cloud data denoising
Recommendation of books related to strong foundation program mathematics
JMeter plug-in installation
Task of gradle learning
随机推荐
强基计划 数学相关书籍 推荐
Geek Daily: the system of monitoring employees' turnover intention has been deeply convinced off the shelves; The meta universe app of wechat and QQ was actively removed from the shelves; IntelliJ pla
Class loading process
Don't be afraid of no foundation. Zero foundation doesn't need any technology to reinstall the computer system
Microsoft: the 12th generation core processor needs to be upgraded to win11 to give full play to its maximum performance
Test access criteria
11-grom-v2-04-advanced query
4. Data binding
Teach you how to quickly recover data by deleting recycle bin files by mistake
Blue Bridge Cup: the fourth preliminary - "simulated intelligent irrigation system"
Camera calibration (I): robot hand eye calibration
AST (Abstract Syntax Tree)
It is discussed that the success of Vit lies not in attention. Shiftvit uses the precision of swing transformer to outperform the speed of RESNET
Task of gradle learning
6006. Take out the minimum number of magic beans
Find a line in a file and remove it
Sword finger offer 30 Stack containing min function
Leetcode daily question solution: 540 A single element in an ordered array
Battle drag method 1: moderately optimistic, build self-confidence (1)
Global and Chinese market of full authority digital engine control (FADEC) 2022-2028: Research Report on technology, participants, trends, market size and share