MYSQL使用范围/限制对所有行和数据分页进行计数 [英] MYSQL Count all rows and pagination of data using range/limit
问题描述
我不知道这是否重复 但这是我的问题.
I dont know if this is a duplicate but here's my question..
我试图对从数据库中获取的数据进行分页
I was trying to implement a pagination of data taken from database
我的困境是:
-
我应该进行分页,成组查询数据,即. 5(使用限制/范围进行选择),然后在具有分页的表中显示它们.它将具有页码,因此将需要对所有表条目进行计数,因此对于初始显示将是2个数据库查询.或
Should i go about pagination, querying data in groups, ie. 5 (doing a Select with limits/ range), then displaying them in a table with pagination. It will have page numbers so it would require counting all the table entries thus that would be 2 database queries for the initial display.or
查询所有行条目,然后计算结果集并应用分页.这将删除数据库上的查询计数,但也意味着每次在任何页面上进行单个视图时,我都会下载全部数据(但我也可以应用缓存)
query all the row entries and then count the result set and apply pagination. This would remove the query count on the database but would also mean that i would download the whole data everytime a single view on any page is made (but i could also apply caching)
和其他建议已被高度接受,并预先感谢
and other suggestions are highly accepted and thank you in advance
推荐答案
这将允许您使用LIMIT并具有未使用限制的行数.
This will allow you to use LIMIT and have the amount of rows as no limit was used.
这篇关于MYSQL使用范围/限制对所有行和数据分页进行计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!