如何限制MySQL中的选择?

时间:2022-03-11 07:15:52

I am confuse on how to limit selection in MySQL (e.g SELECT * FROM tblProduction LIMIT 1,N;) where N is unknown.. Can anyone help me on how can I limit the selection in MySQL? I want to show the records starting from row 2 (two) up to the end of the records. Thanks!

我很困惑如何在MySQL中限制选择(e。g从tblProduction LIMIT 1,N;)中选择*,其中N是未知的。谁能帮我限制MySQL的选择吗?我要显示从第2行(2)到记录末尾的记录。谢谢!

2 个解决方案

#1


6  

This is from the LIMIT documentation:

这是来自极限文件:

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:

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

SELECT * FROM tbl LIMIT 95,18446744073709551615;

EDIT: So in your case you would just change 95 to 2. Then you would get all rows starting from the 2 result.

编辑:在你的例子中,你只需将95改为2。然后你会得到从2个结果开始的所有行。

#2


-2  

Hi you can either pass the N value by Query string or some cookie.

你好,你可以通过查询字符串或一些cookie传递N值。

"SELECT * FROM tblProduction LIMIT 1,".$_GET[Limit];

#1


6  

This is from the LIMIT documentation:

这是来自极限文件:

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:

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

SELECT * FROM tbl LIMIT 95,18446744073709551615;

EDIT: So in your case you would just change 95 to 2. Then you would get all rows starting from the 2 result.

编辑:在你的例子中,你只需将95改为2。然后你会得到从2个结果开始的所有行。

#2


-2  

Hi you can either pass the N value by Query string or some cookie.

你好,你可以通过查询字符串或一些cookie传递N值。

"SELECT * FROM tblProduction LIMIT 1,".$_GET[Limit];