当前位置:网站首页>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;
边栏推荐
猜你喜欢

第六天 脚本与动画系统

Understand 12 convolution methods (including 1x1 convolution, transpose convolution and deep separable convolution)

接口自动化框架脚手架-参数化工具的实现

Training and recognition of handwritten digits through the lenet-5 network built by pytorch

Discard Tkinter! Simple configuration to quickly generate cool GUI!

增强 Jupyter Notebook 的功能,这里有四个妙招

移动命令

【实操】Appium Settings app is not running after 5000ms

无线模块透明传输技术的物联网应用案例
![[Unity][ECS]学习笔记(二)](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[Unity][ECS]学习笔记(二)
随机推荐
Unity AssetBundle asset packaging and asset loading
An idea plug-in that automatically generates unit tests, which improves the development efficiency by more than 70%!
sentinel
Fabric. How to use js brush?
【功能建议】多个工作空间启动时选择某个空间
Cisco * VRF(虚拟路由转发表)
股票开户用中金证券经理发的开户二维码安全吗?知道的给说一下吧
Cisco * VRF (virtual route forwarding table)
Interface automation framework scaffold - use reflection mechanism to realize the unified initiator of the interface
As shown in the figure, the SQL row is used to convert the original table of Figure 1. Figure 2 wants to convert it
Hystrix 部署
Ribbon核心源码解析
无线模块透明传输技术的物联网应用案例
Who knows if it is safe to open an account with CSC securities
etf持仓如何影响现货金价?
MySQL cannot be opened. Flash back
解决表单action属性传参时值为null的问题
Starting from full power to accelerate brand renewal, Chang'an electric and electrification products sound the "assembly number"
Katalon当中的debug调试
Six fusion positioning technologies in wireless communication application of Internet of things