Drag from mysql with counting and limiting
Is it possible to create a drag from mysql and count the total number of rows, but 开发者_如何转开发only get 20 rows at a time?
I don't know what you mean with "drag", but yes you can use SQL_CALC_FOUND_ROWS to retrieve 20 rows while still counting the total number of rows matching your criteria:
SELECT SQL_CALC_FOUND_ROWS * FROM table WHERE ... LIMIT 20;
Then call FOUND_ROWS()
in another query to fetch the total number of rows matched:
SELECT FOUND_ROWS();
精彩评论