当前位置:网站首页>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
边栏推荐
- Report on the development strategy of China's engineering bidding agency and suggestions for the 14th five year plan Ⓙ 2022 ~ 2028
- 仿网易云音乐小程序
- Solve the problem that openocd fails to burn STM32 and cannot connect through SWD
- Collections SQL communes
- Covariance
- UI automation test: selenium+po mode +pytest+allure integration
- Great gods, I want to send two broadcast streams: 1. Load basic data from MySQL and 2. Load changes in basic data from Kafka
- WiFi 2.4g/5g/6g channel distribution
- Development trend and market demand analysis report of China's energy storage battery industry Ⓩ 2022 ~ 2028
- 十大券商开户注册安全靠谱吗?有没有风险的?
猜你喜欢
Kali2021.4a build PWN environment
使用dnSpy对无源码EXE或DLL进行反编译并且修改
Advanced technology management - how to examine candidates in the interview and increase the entry probability
Blue Bridge Cup Guoxin Changtian MCU -- program download (III)
[SRS] build a specified version of SRS
Dahua series books
MySQL——idea连接MySQL
Imitation Netease cloud music applet
A little understanding of GSLB (global server load balance) technology
Asynchronous artifact: implementation principle and usage scenario of completable future
随机推荐
Compréhension de la technologie gslb (Global Server load balance)
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
Common SQL sets
How to install sentinel console
Let me ask you a question. Have you ever used the asynchronous io of Flink SQL to associate dimension tables in MySQL? I set various settings according to the official website
JS Demo calcule combien de jours il reste de l'année
[dynamic planning] counting garlic customers: the log of garlic King (the longest increasing public subsequence)
MySQL - database backup
A little understanding of GSLB (global server load balance) technology
使用dnSpy对无源码EXE或DLL进行反编译并且修改
On my first day at work, this API timeout optimization put me down!
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
Go language slice interview real question 7 consecutive questions
Monkey/ auto traverse test, integrate screen recording requirements
QFileDialog
鹏城杯 WEB_WP
2022 high altitude installation, maintenance and removal of examination question bank and high altitude installation, maintenance and removal of examination papers
How to store null value on the disk of yyds dry inventory?
[vulnhub shooting range] impulse: lupinone
treevalue——Master Nested Data Like Tensor