Get total number of rows when using LIMIT

前端 未结 2 962
旧巷少年郎
旧巷少年郎 2021-02-14 20:03

Been following examples from here and many other sites but not getting the expected results

Snippet of my PHP code;

$query=\"SELECT * FROM book\";
$resul         


        
2条回答
  •  余生分开走
    2021-02-14 20:57

    Your most recent query returned 4 rows ($query="SELECT * FROM book LIMIT 0,4";).

    That's why it returns 4 and not 14.


    To quote the documentation:

    In the absence of the SQL_CALC_FOUND_ROWS option in the most recent successful SELECT statement, FOUND_ROWS() returns the number of rows in the result set returned by that statement. If the statement includes a LIMIT clause, FOUND_ROWS() returns the number of rows up to the limit.

提交回复
热议问题