mysql 前10 后10_如何在MySQL中跳过前10个结果?

要跳过前10个结果,请使用“极限偏移”。语法如下-select *from yourTableName limit 10 offset lastValue;

让我们创建一个表来了解上述语法。以下是创建表的查询-mysql> create table SkipFirstTenRecords

−> (

−> StudentId int,

−> StudentName varchar(200)

−> );

现在,您可以借助insert命令在表中插入一些记录。查询如下-mysql> insert into SkipFirstTenRecords values(100,'John');

mysql> insert into SkipFirstTenRecords values(101,'Johnson');

mysql> insert into SkipFirstTenRecords values(102,'Carol');

mysql> insert into SkipFirstTenRecords values(103,'Smith');

mysql> insert into SkipFirstTenRecords values(104,'Bob');

mysql> insert into SkipFirstTenRecords values(105,'David');

mysql> insert into SkipFirstTenRecords values(106,'Sam');

mysql> insert into SkipFirstTenRecords values(107,'Taylor');

mysql> insert into SkipFirstTenRecords values(108,'Ramit');

mysql> insert into SkipFirstTenRecords values(109,'Belly');

mysql> insert into SkipFirstTenRecords values(110,'Aaron ');

mysql> insert into SkipFirstTenRecords values(111,'Peter');

mysql> insert into SkipFirstTenRecords values(112,'Travis');

mysql> insert into SkipFirstTenRecords values(113,'Alex');

mysql> insert into SkipFirstTenRecords values(114,'Pat ');

Display all records which I have inserted in the table. The query is as follows:

mysql> select *from SkipFirstTenRecords;

以下是输出-+-----------+-------------+

| StudentId | StudentName |

+-----------+-------------+

|       100 | John        |

|       101 | Johnson     |

|       102 | Carol       |

|       103 | Smith       |

|       104 | Bob         |

|       105 | David       |

|       106 | Sam         |

|       107 | Taylor      |

|       108 | Ramit       |

|       109 | Belly       |

|       110 | Aaron       |

|       111 | Peter       |

|       112 | Travis      |

|       113 | Alex        |

|       114 | Pat         |

+-----------+-------------+

15 rows in set (0.00 sec)

跳过上表中的前10条记录的查询全部如下-mysql> select *from SkipFirstTenRecords limit 10 offset 10;

以下是自我们跳过前10条记录以来的输出,仅显示最后5条记录-+-----------+-------------+

| StudentId | StudentName |

+-----------+-------------+

|        110 | Aaron      |

|        111 | Peter      |

|        112 | Travis     |

|        113 | Alex       |

|        114 | Pat        |

+-----------+-------------+

5 rows in set (0.00 sec)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值