当前位置:网站首页>Introduction and advanced level of MySQL (11)
Introduction and advanced level of MySQL (11)
2022-07-29 03:09:00 【Xiaoxinai programming】
Query result set as ⼀ Virtual tables directly participate in the query
Eg: Query the learning of each class ⽣ Number , And sort in reverse order according to the number
Eg2: List the men in each class ⽣⼥⽣⽐ example
/* Subquery :
Query nesting
- Query results are used directly as virtual tables
- The query result is used as the value of the judgment condition
- The query result is used as the value of the assignment update set a= value ? You can also use subquery
Subquery :
The location of the queried table
Query condition location
delete Search condition location of
update The location of the search condition
update set The position of assignment can also
insert The position of writing value can also be used */
-- The query result is used as a table , Alias is required
17 -- Query the number of students in each class , Sort by flashback
18 select a.classname,count(b.studentid)
19 from class a
20 left join studentinfo b on a.classid=b.classid
21 group by a.classid,a.classname
22 order by count(b.studentid) desc
234 select * from(
25 select a.classname,count(b.studentid) as stucount
26 from class a
27 left join studentinfo b on a.classid=b.classid
28 group by a.classid,a.classname
29 )a
30 order by a.stucount desc
312 -- List the proportion of boys and girls in each class
33 select nvcount/nancount,a.classid from(
34 select count(*) as nvcount,gender,classid
35 from studentinfo
36 where gender=' Woman '
37 group by classid
38 )a
39 left join(
40 select count(*) as nancount,gender,classid
41 from studentinfo
42 where gender=' male '
43 group by classid
44 )b on a.classid=b.classid
边栏推荐
- 算法---粉刷房子(Kotlin)
- 【C】数组
- VIM common commands
- 单例模式(饿汉式 懒汉式)
- Shell编程规范与变量
- Navicat new database
- MySQL large table joint query optimization, large transaction optimization, avoiding transaction timeout, lock wait timeout and lock table
- 4000 多字学懂弄通 js 中 this 指向问题,顺便手写实现 call、apply 和 bind
- What is SOA (Service Oriented Architecture)?
- Algorithm --- paint the house (kotlin)
猜你喜欢

12_ue4进阶_换一个更好看的人物模型

基于单片机烟雾温湿度甲醛监测设计

01-sdram: Code of initialization module

2022-07-28 顾宇佳 学习笔记

mycat读写分离配置
![[freeswitch development practice] unimrcp compilation and installation](/img/ef/b82326152326293bf98e89da28b887.png)
[freeswitch development practice] unimrcp compilation and installation

微信为之疯狂的Glide使用——之生命周期学习

My approval function of conference OA project

STC单片机驱动1.8‘TFT SPI屏幕演示示例(含资料包)

Plato Farm在Elephant Swap上铸造的ePLATO是什么?为何具备高溢价?
随机推荐
算法---粉刷房子(Kotlin)
Navicat new database
力扣刷题之数组序号计算(每日一题7/28)
MySQL - the difference between count (field), count (primary key), count (1), count (*)
C语言程序设计 | 交换二进制数奇偶位(宏实现)
TP5.0 小程序用户无需登录,直接获取用户手机号。
Alibaba Sentinel - 工作流程及原理解析
MySQL operation database data error: fatal error encoded during command execution
带你来浅聊一下,单商户功能模块汇总
力扣刷题之分数加减运算(每日一题7/27)
C陷阱与缺陷 第3章 语义“陷阱” 3.9 整数溢出
生产部署zabbix5.0笔记
《QA离业务代码能有多近?》QA对业务代码进行可测性改造
C and pointer Chapter 3 semantic "trap" 3.5 null pointer is not a string
What is SOA (Service Oriented Architecture)?
04 | 后台登录:基于账号密码的登录方式(上)
2022-07-28 第四小组 修身课 学习笔记(every day)
Chapter 09_ Use of performance analysis tools
《QA离业务代码能有多近?》通过codediff直接暴露缺陷
Analysis of Project-based Learning Creativity in steam Education