MySQL Data - Best way to implement paging?

后端 未结 7 1201
灰色年华
灰色年华 2020-11-22 09:32

My iPhone app connects to my PHP web service to retrieve data from a MySQL database. A request can return 500 results.

What is the best way to implement paging and r

7条回答
  •  無奈伤痛
    2020-11-22 10:12

    you can also do

    SELECT SQL_CALC_FOUND_ROWS * FROM tbl limit 0, 20
    

    The row count of the select statement (without the limit) is captured in the same select statement so that you don't need to query the table size again. You get the row count using SELECT FOUND_ROWS();

提交回复
热议问题