Skip to content

Commit 3bcf6bf

Browse files
committed
更新了部分文档
1 parent c6ef269 commit 3bcf6bf

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

Diff for: res/all_in_one.png

39.1 KB
Loading

Diff for: 第47课.MySQL新特性.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,14 @@ select * from (
159159
) `temp` where `rank` between 4 and 6;
160160
```
161161

162-
> **说明**上面使用的函数`row_number()`可以为每条记录生成一个行号,在实际工作中可以根据需要将其替换为`rank()``dense_rank()`函数,三者的区别可以参考官方文档或阅读[《通俗易懂的学会:SQL窗口函数》](https://zhuanlan.zhihu.com/p/92654574)进行了解。在MySQL 8以前的版本,我们可以通过下面的方式来完成类似的操作。
163-
>
164-
> ```SQL
165-
> select `rank`, `ename`, `sal` from (
166-
> select @a:=@a+1 as `rank`, `ename`, `sal`
167-
> from `tb_emp`, (select @a:=0) as t1 order by `sal` desc
168-
> ) as `temp` where `rank` between 4 and 6;
169-
> ```
162+
上面使用的函数`row_number()`可以为每条记录生成一个行号,在实际工作中可以根据需要将其替换为`rank()``dense_rank()`函数,三者的区别可以参考官方文档或阅读[《通俗易懂的学会:SQL窗口函数》](https://zhuanlan.zhihu.com/p/92654574)进行了解。在MySQL 8以前的版本,我们可以通过下面的方式来完成类似的操作。
163+
164+
```SQL
165+
select `rank`, `ename`, `sal` from (
166+
select @a:=@a+1 as `rank`, `ename`, `sal`
167+
from `tb_emp`, (select @a:=0) as t1 order by `sal` desc
168+
) as `temp` where `rank` between 4 and 6;
169+
```
170170

171171
例子2:查询每个部门月薪最高的两名的员工的姓名和部门名称。
172172

@@ -180,13 +180,13 @@ from (
180180
) as `temp` natural join `tb_dept` where `rank`<=2;
181181
```
182182

183-
> 说明:在MySQL 8以前的版本,我们可以通过下面的方式来完成类似的操作。
184-
>
185-
> ```SQL
186-
> select `ename`, `sal`, `dname` from `tb_emp` as `t1`
183+
说明:在MySQL 8以前的版本,我们可以通过下面的方式来完成类似的操作。
184+
185+
```SQL
186+
select `ename`, `sal`, `dname` from `tb_emp` as `t1`
187187
natural join `tb_dept`
188188
where (
189-
select count(*) from `tb_emp` as `t2`
190-
where `t1`.`dno`=`t2`.`dno` and `t2`.`sal`>`t1`.`sal`
189+
select count(*) from `tb_emp` as `t2`
190+
where `t1`.`dno`=`t2`.`dno` and `t2`.`sal`>`t1`.`sal`
191191
)<2 order by `dno` asc, `sal` desc;
192-
> ```
192+
```

0 commit comments

Comments
 (0)