当前位置:网站首页>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;
边栏推荐
- Interface automation framework scaffolding - Implementation of parametric tools
- Read PDF image and identify content
- 树莓派无需显示屏的VNC Viewer方式的远程连接
- How to distinguish and define DQL, DML, DDL and DCL in SQL
- MySQL cannot be opened. Flash back
- Understanding of FTP protocol
- Understand 12 convolution methods (including 1x1 convolution, transpose convolution and deep separable convolution)
- Mysql通用二进制安装方式
- Information hidden in the trend chart of Hong Kong London gold market
- 【力扣——动态规划】整理题目1:基础题目:509、70、746、62、63、343、96(附链接、题目描述、解题方法及代码)
猜你喜欢

How to distinguish and define DQL, DML, DDL and DCL in SQL

一种跳板机的实现思路

The boss asked me to write an app automation -- yaml file reading -- with the whole framework source code attached

How to use dataant to monitor Apache apisex
![[Unity][ECS]学习笔记(二)](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[Unity][ECS]学习笔记(二)

Metersphere实现UI自动化元素不可点击(部分遮挡)

mysql数据库概述以及安装过程

树莓派无需显示屏的VNC Viewer方式的远程连接

Mysql通用二进制安装方式

第六天 脚本与动画系统
随机推荐
解决表单action属性传参时值为null的问题
一款自动生成单元测试的 IDEA 插件,开发效率提升 70% 以上!
压缩解压
Understanding of FTP protocol
股票开户用中金证券经理发的开户二维码安全吗?知道的给说一下吧
Interface automation framework scaffold - use reflection mechanism to realize the unified initiator of the interface
Cisco * VRF(虚拟路由转发表)
[Unity][ECS]学习笔记(三)
Idea failed to connect to SQL Sever
etf持仓如何影响现货金价?
Training and recognition of handwritten digits through the lenet-5 network built by pytorch
appliedzkp zkevm(10)中的Transactions Proof
Ble Bluetooth module nrf518/nrf281/nrf528/nrf284 chip scheme comparison
Must the MySQL table have a primary key for incremental snapshots?
Correct conversion between JSON data and list collection
Please consult me. I run the MYSQL to MySQL full synchronization of flykcdc in my local ide. This is in my local ide
Install using snap in opencloudos NET 6
第三章 栈和队列
To enhance the function of jupyter notebook, here are four tips
Realize an air conditioner with compose to bring you cool in summer