选择使用MySQL LIMIT和OFFSET查询所有记录 [英] Select all records using MySQL LIMIT and OFFSET query

查看:710
本文介绍了选择使用MySQL LIMIT和OFFSET查询所有记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方式来完成:

I'm looking for a way to accomplish:

SELECT * FROM table

但通过使用限制 OFFSET 像这样:

SELECT * FROM table LIMIT all OFFSET 0

有没有编写SQL语句的使用限制的方式和OFFSET,但仍让所有的结果呢?
(当然,我可以使用如果语句,但我宁愿避免可能的话)

Is there a way of writing SQL statement using LIMIT and OFFSET but still getting ALL result?
(Of course I can use an IF statement but I rather avoid it if possible)

任何帮助将是AP preciated!

Any help would be appreciated!

推荐答案

MySQL文档< /一>:

From the MySQL documentation:

要取回所有行从某个偏移到结果的末尾   集,你可以使用一些大量的第二个参数。本   语句检索从第96行的所有行到最后:

To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last:

SELECT * FROM TBL LIMIT 95,18446744073709551615;

SELECT * FROM tbl LIMIT 95,18446744073709551615;

所以让所有的行可能如下所示:

So getting all rows might look as follows:

SELECT * FROM tbl LIMIT 0,18446744073709551615;

这篇关于选择使用MySQL LIMIT和OFFSET查询所有记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆