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

边栏推荐
- 6. Data agent object Defineproperty method
- JMeter connection database
- Camera calibration (I): robot hand eye calibration
- How to read the source code [debug and observe the source code]
- Network security Kali penetration learning how to get started with web penetration how to scan based on nmap
- Professional interpretation | how to become an SQL developer
- Teach you how to quickly recover data by deleting recycle bin files by mistake
- Exercises of function recursion
- 2.7 format output of values
- Bool blind note - score query
猜你喜欢

The 15 year old interviewer will teach you four unique skills that you must pass the interview
![[Yu Yue education] basic reference materials of manufacturing technology of Shanghai Jiaotong University](/img/95/5baf5c8bedb00e67394a6c0a8234ff.png)
[Yu Yue education] basic reference materials of manufacturing technology of Shanghai Jiaotong University

How to improve data security by renting servers in Hong Kong

Promethus

How to do Taobao full screen rotation code? Taobao rotation tmall full screen rotation code

How to modify the network IP addresses of mobile phones and computers?

Vscode reports an error according to the go plug-in go get connectex: a connection attempt failed because the connected party did not pro

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

Node MySQL serialize cannot rollback transactions

Network security Kali penetration learning how to get started with web penetration how to scan based on nmap
随机推荐
Leetcode daily question solution: 540 A single element in an ordered array
Promethus
Node MySQL serialize cannot rollback transactions
Basic knowledge of dictionaries and collections
Utilisation de base du cadre unitest
Global and Chinese market of full authority digital engine control (FADEC) 2022-2028: Research Report on technology, participants, trends, market size and share
5- (4-nitrophenyl) - 10,15,20-triphenylporphyrin ntpph2/ntppzn/ntppmn/ntppfe/ntppni/ntppcu/ntppcd/ntppco and other metal complexes
Teach you how to quickly recover data by deleting recycle bin files by mistake
How to do Taobao full screen rotation code? Taobao rotation tmall full screen rotation code
Print linked list from end to end
Rad+xray vulnerability scanning tool
Gym welcomes the first complete environmental document, which makes it easier to get started with intensive learning!
Acquisition and transmission of parameters in automatic testing of JMeter interface
Global and Chinese market of micro positioning technology 2022-2028: Research Report on technology, participants, trends, market size and share
Nacos usage of micro services
Rd file name conflict when extending a S4 method of some other package
IP address is such an important knowledge that it's useless to listen to a younger student?
Global and Chinese market of high purity copper foil 2022-2028: Research Report on technology, participants, trends, market size and share
Golang type assertion and conversion (and strconv package)
The simplicity of laravel