当前位置:网站首页>MySQL (II)
MySQL (II)
2022-06-28 10:36:00 【0&1 * 1】
One 、 filter
1) Comparison operator
select * from student where id>2;
select * from student where id<>2;
select * from student where id is not Null;
2) Logical operators
select * from student where id=1 and name='fei';
select * from student where id=1 or name='fei';
select * from student where not name='fei';
Sort (order by)
select * from student order by class;
select *from student order by class desc;
. Limit (limit)
select * from student limit 3;
select * from student limit 5,3;
. duplicate removal (distinct)
select distinct * from student ;
Fuzzy query
select * from student where name like 'k%";
select * from student where name like 'k_";
select * from student where name like 'k__";
Two 、 Aggregation and grouping
1) Common aggregate functions
1. Number of Statistics :
count (column)
select count(name)from student;
2. Maximum :
max (column)
select max(name)from student;
3. minimum value :
min(column)
select min(name)from student
4. Sum up :
sum (column)
select sum(name)from student;
5. Average :
avg (column)
select avg(name)from student;
6. List all field values
:group_concat (column)
select group_concat(name)from student;
2) Group query
(group by )
select class from student group by class;
select class,group_concat(name) from student group by class;
3) Aggregate filter
1.(having)
select class,group_concat(name) from student where id<5 group by class having class=2;
select class,group_concat(name) as gg from student where id<5 group by class having class=2
3、 ... and 、 Subquery
1) Definition
1. Leave the results of one query for the next query ( select Nested in select )
for example : requirement :1) Nested inside the query 2) Must always appear in parentheses
Find the average age of the students ``
select avg(age) from student;
Of the average age to be determined SQL Statement is used to find statements that are older than the average age
Of the average age to be determined SQL Statement is used to find statements that are older than the average age
Four 、 Link query
1) Internal connection ( inner join)
1. Unconditional internal connection :
Unconditional internal connection , Also known as cross connect / Cartesian connection
Each item of the first table will be combined with each item of the other table in turn
Mysql> select * from student [inner] join detail;
2. Conditional inner connection :
On the basis of unconditional inner link , Add a on Clause
When connected , Filter out those meaningful records for combination
Mysql> select * from student inner join detail
on student.id =detail.id;
select student.id,name,age from student join detail
on student.id =detail.id;
2) External connection ({left | right} join)
1. The left outer join : ( Based on the left table )
When two tables are connected , When the connection conditions don't match
Leave the data in the left table , The data in the right table is represented by NULL fill
mysql> select student.id,name,age from student right join detail on student.id =detail.id;
2. Right connection : ( Based on the right table )
When connecting two tables , When the connection conditions don't match
Leave the data in the right table , The data in the left table is represented by NULL fill
mysql> select student.id,name,age from student left join detail on student.id =detail.id;
边栏推荐
- What is the difference between MySQL development environment and test environment??
- Internet of things application case of wireless module transparent transmission technology
- Must the MySQL table have a primary key for incremental snapshots?
- 【力扣——动态规划】整理题目1:基础题目:509、70、746、62、63、343、96(附链接、题目描述、解题方法及代码)
- 股票开户用中金证券经理发的开户二维码安全吗?知道的给说一下吧
- Ideal interface automation project
- fastposter v2.8.4 发布 电商海报生成器
- [unity][ecs] learning notes (II)
- datetime与logging模块
- Minimum stack < difficulty coefficient >
猜你喜欢

Interface automation framework scaffold - use reflection mechanism to realize the unified initiator of the interface

学习机器学习的最佳路径是什么

Day 6 script and animation system

DataEase安装升级

sentinel

Mysql database overview and installation process
![[NLP] this year's college entrance examination English AI score is 134. The research of Fudan Wuda alumni is interesting](/img/a8/51b95432a9c8f25d8440cfd80926ce.png)
[NLP] this year's college entrance examination English AI score is 134. The research of Fudan Wuda alumni is interesting
![[Unity][ECS]学习笔记(一)](/img/eb/1f0ad817bbc441fd8c14d046b82dd0.png)
[Unity][ECS]学习笔记(一)
![[unity][ecs] learning notes (II)](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[unity][ecs] learning notes (II)

Interface automation framework scaffolding - Implementation of parametric tools
随机推荐
What is the best way to learn machine learning
Unity AssetBundle asset packaging and asset loading
手把手教你处理 JS 逆向之 SVG 映射
MySQL common commands for viewing database performance
Katalon当中的output使用方法
一款自动生成单元测试的 IDEA 插件,开发效率提升 70% 以上!
Cisco * VRF (virtual route forwarding table)
As shown in the figure, the SQL row is used to convert the original table of Figure 1. Figure 2 wants to convert it
etf持仓如何影响现货金价?
Ribbon核心源码解析
ECS MySQL query is slow
Missed the golden three silver four, found a job for 4 months, interviewed 15 companies, and finally got 3 offers, ranking P7+
[unity][ecs] learning notes (II)
Summary of characteristics of five wireless transmission protocols of Internet of things
Set up your own website (11)
Dotnet uses crossgen2 to readytorun DLL to improve startup performance
Realization of a springboard machine
2D code generator for openharmony application development
An idea plug-in that automatically generates unit tests, which improves the development efficiency by more than 70%!
To enhance the function of jupyter notebook, here are four tips