当前位置:网站首页>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
边栏推荐
- 使用dnSpy对无源码EXE或DLL进行反编译并且修改
- Tkinter Huarong Road 4x4 tutorial III
- Memory analyzer (MAT)
- Bluebridge cup Guoxin Changtian single chip microcomputer -- detailed explanation of schematic diagram (IV)
- 2022 free examination questions for safety management personnel of hazardous chemical business units and reexamination examination for safety management personnel of hazardous chemical business units
- 内存分析器 (MAT)
- Capturing and sorting out external articles -- autoresponder, composer, statistics [III]
- China HDI market production and marketing demand and investment forecast analysis report Ⓢ 2022 ~ 2028
- MySQL——JDBC
- UI automation test: selenium+po mode +pytest+allure integration
猜你喜欢
Functions and differences between static and Const
The post-90s resigned and started a business, saying they would kill cloud database
Why use pycharm to run the use case successfully but cannot exit?
Morning flowers and evening flowers
QFileDialog
Bluebridge cup Guoxin Changtian single chip microcomputer -- detailed explanation of schematic diagram (IV)
Minio deployment
The latest analysis of crane driver (limited to bridge crane) in 2022 and the test questions and analysis of crane driver (limited to bridge crane)
Tidb's initial experience of ticdc6.0
MySQL——JDBC
随机推荐
Minio deployment
Collections SQL communes
What if the Flink SQL client exits and the table is emptied?
使用dnSpy对无源码EXE或DLL进行反编译并且修改
Investment planning analysis and prospect prediction report of China's satellite application industry during the 14th five year plan Ⓑ 2022 ~ 2028
flink sql-client 退出,表就会被清空怎么办?
90 後,辭職創業,說要卷死雲數據庫
MySQL -- standardize database design
treevalue——Master Nested Data Like Tensor
What should the future of the Internet be like when Silicon Valley employees flee the big factory and rush to Web3| Footprint Analytics
使用dnSpy對無源碼EXE或DLL進行反編譯並且修改
[dynamic programming] Jisuan Ke: Jumping stake (variant of the longest increasing subsequence)
Tidb's initial experience of ticdc6.0
DR882-Qualcomm-Atheros-QCA9882-2T2R-MIMO-802.11ac-Mini-PCIe-Wi-Fi-Module-5G-high-power
Correlation
The 14th five year plan and investment feasibility study report of China's industry university research cooperation Ⓧ 2022 ~ 2028
MySQL——索引
Bluebridge cup Guoxin Changtian single chip microcomputer -- detailed explanation of schematic diagram (IV)
DOM light switch case
Control loop of program (while loop)