当前位置:网站首页>Mysql database - Advanced SQL statement (I)
Mysql database - Advanced SQL statement (I)
2022-07-03 22:00:00 【Seal nine FJ】
MySQL High level statements
Prepare two tables first

One 、SELECT—— Display all data of one or more fields in the table

Two 、DISTINCT—— Don't show duplicate data

3、 ... and 、WHERE------ Conditional query

Four 、AND|OR—— And | or

5、 ... and 、IN—— Display information about known values

6、 ... and 、BETWEEN—— Displays data in two ranges

7、 ... and 、 wildcard —— Usually, wildcards are used with LIKE Used together


8、 ... and 、LIKE—— Match a pattern to find out what we want

Nine 、ORDER BY—— Sort by keyword

Ten 、 function
1) Mathematical functions

2) Aggregate functions

3) String function
- trim() Returns a value with the specified format removed

- concat(x,y) The parameters that will be provided x and y Concatenate into a string

- substr(x,y) Get from string x No y A string starting at a position , Follow substring() Functions work the same
- substr(x,y,z) Get from string x No y The starting length of a position is z String

- length(x) Return string x The length of

- replace(x,y,z) The string z Alternative string x String in y

- upper(x) The string x All of the letters of the alphabet become capital letters
- lower(x) The string x All of the letters of the are changed into lower case letters

- left(x,y) Return string x Before y Characters
- right(x,y) Return string x After y Characters

- repeat(x,y) The string x repeat y Time

- space(x) return x A space

- strcmp(x,y) Compare x and y, The value returned can be -1,0,1

- reverse(x) The string x reverse

11、 ... and 、GROUP BY—— Yes GROUP BY Summarize and group the query results in the following fields
- Usually used in combination with aggregate functions
- GROUP BY There is a principle , Namely SELECT In all the following columns , Columns that do not use aggregate functions , Must appear in GROUP BY Back .

Twelve 、HAVING—— Used to filter by GROUP BY Statement returns a record table ***
- Usually with GROUP BY Statements are used in conjunction with
- HAVING The existence of sentences makes up for WHERE Keywords cannot be combined with aggregate functions . If you are SELECT Only the function bar , Then there is no need for GROUP BY Clause .

13、 ... and 、 Alias —— Field alias , Table alias

fourteen 、 Subquery : Connect tables
- Son WHERE Clause or HAVING Clause to insert another SQL sentence


15、 ... and 、EXISTS—— It is used to test whether the inner query produces any results
- Whether Boolean value is true or not
- If any , The system will execute the SQL sentence . If not , The whole SQL Statement will not produce any results

Link query
1. inner join( It's equivalent )
- Only rows with equal join fields in two tables are returned

2. left join( Left join )
- Returns records that include all records in the left table and join fields in the right table

3. right join( Right link )
- Returns records that include all records in the right table and join fields in the left table

CREATE VIEW View
It can be treated as a virtual table or stored query
Views are different from tables , A view is an architecture based on a table , It doesn't actually store data itself
Trying to be different from the temporary table , The user will not disappear after exiting or disconnecting from the database
Views don't contain data , Only store definitions , It can simplify complex queries , If you query several tables , When you also need to perform operations such as statistical sorting , Write sql Sentences are cumbersome , We can simplify queries with a common view

边栏推荐
- treevalue——Master Nested Data Like Tensor
- MySQL——JDBC
- Solve the problem that openocd fails to burn STM32 and cannot connect through SWD
- treevalue——Master Nested Data Like Tensor
- Global and Chinese market of wall mounted kiosks 2022-2028: Research Report on technology, participants, trends, market size and share
- Solve the problem that openocd fails to burn STM32 and cannot connect through SWD
- Collections SQL communes
- Nacos common configuration
- DR-AP40X9-A-Qualcomm-IPQ-4019-IPQ-4029-5G-4G-LTE-aluminum-body-dual-band-wifi-router-2.4GHZ-5GHz-QSD
- Après 90 ans, j'ai démissionné pour démarrer une entreprise et j'ai dit que j'allais détruire la base de données Cloud.
猜你喜欢

Blue Bridge Cup Guoxin Changtian single chip microcomputer -- led lamp module (V)

Nacos common configuration

常用sql集合

Covariance

treevalue——Master Nested Data Like Tensor

Après 90 ans, j'ai démissionné pour démarrer une entreprise et j'ai dit que j'allais détruire la base de données Cloud.

UI automation test: selenium+po mode +pytest+allure integration

Imitation Netease cloud music applet

Collection | pytoch common loss function disassembly

常用sql集合
随机推荐
常用sql集合
MySQL——JDBC
Minio deployment
MySQL - database backup
A little understanding of GSLB (global server load balance) technology
内存分析器 (MAT)
The post-90s resigned and started a business, saying they would kill cloud database
Is it safe and reliable to open an account and register for stock speculation? Is there any risk?
Cognitive fallacy: what is dimensional curse
90 后,辞职创业,说要卷死云数据库
The 14th five year plan and investment feasibility study report of China's industry university research cooperation Ⓧ 2022 ~ 2028
MySQL——idea连接MySQL
2022 safety officer-b certificate examination summary and safety officer-b certificate simulation test questions
Preliminary understanding of C program design
Global and Chinese market of AC induction motors 2022-2028: Research Report on technology, participants, trends, market size and share
The 14th five year plan for the construction of Chinese Enterprise Universities and the feasibility study report on investment Ⓓ 2022 ~ 2028
How PHP adds two numbers
Collections SQL communes
Mysql - - Index
Tkinter Huarong Road 4x4 tutorial III