当前位置:网站首页>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;
边栏推荐
- 2022吴恩达机器学习specialization Week 2 practice lab: Linear regression
- Fastposter v2.8.4 release e-commerce poster generator
- Summary of characteristics of five wireless transmission protocols of Internet of things
- ICMP协议的作用,Ping of Death攻击的原理是什么?
- Six fusion positioning technologies in wireless communication application of Internet of things
- An error is reported when uninstalling Oracle
- 增量快照 必须要求mysql表有主键的吗?
- metersphere使用js刷新当前页面
- Crawler small operation
- DataEase安装升级
猜你喜欢
sentinel
Ribbon core source code analysis
mysql数据库概述以及安装过程
BLE蓝牙模块NRF518/NRF281/NRF528/NRF284芯片方案对比
The boss asked me to write an app automation -- yaml file reading -- with the whole framework source code attached
【NLP】今年高考英语AI得分134,复旦武大校友这项研究有点意思
idea连接sql sever失败
如何利用k线图做技术分析
接口自动化框架脚手架-利用反射机制实现接口统一发起端
[Unity][ECS]学习笔记(二)
随机推荐
metersphere使用js刷新当前页面
满电出发加速品牌焕新,长安电动电气化产品吹响“集结号”
Fastposter v2.8.4 release e-commerce poster generator
June training (day 28) - Dynamic Planning
[Unity]内置渲染管线转URP
Ideal interface automation project
[Unity]EBUSY: resource busy or locked
[Unity][ECS]学习笔记(一)
Hystrix 部署
Summary of characteristics of five wireless transmission protocols of Internet of things
增强 Jupyter Notebook 的功能,这里有四个妙招
MySQL general binary installation method
I'm almost addicted to it. I can't sleep! Let a bug fuck me twice!
Guangzhou Customs supports the stable supply of food, agricultural products, traditional Chinese medicine and other civilian and biological resources to Hong Kong
MySQL(二)
移动命令
Wireless communication module fixed-point transmission - point to multipoint specific transmission application
如何利用k线图做技术分析
解决表单action属性传参时值为null的问题
Metersphere实现UI自动化元素不可点击(部分遮挡)