Skip to content

数据库/LIMIT分页查询的错误 #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions 数据库/数据库.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ SELECT * FROM Student ORDER BY Sage;
SELECT * FROM Student ORDER BY Sdept, Sage desc; //先按专业升序排序,然后同一专业按年龄降序排序
```


### 4)LIMIT

> 可以用于强制`SELECT`返回指定的记录数
Expand All @@ -269,6 +270,23 @@ SELECT * FROM Student ORDER BY Sdept, Sage desc; //先按专业升序排序,
SELECT * FROM Student LIMIT 5, 10; //返回记录行6-15
SELECT * FROM Student LIMIT 5; //返回前5个记录行
```
**修改**
### 4)LIMIT

```sql
SELECT * FROM Students LIMIT <M> OFFSET <N>
```
> 分页查询相关内容

* 1个参数LIMIT <M> 表示显示页的容量 pageSize
* 2个参数OFFSET <N> N由要查询的页数确定 pageSize*(pageIndex-1)

```sql
SELECT * FROM Students LIMIT 4 OFFSET 0 //每页四条记录值,查询第一页
SELECT * FROM Students LIMIT 4, 0;
SELECT * FROM Student LIMIT 5, 10; //返回记录行10-15
```


### 5)聚集函数

Expand Down