开发者

Drag from mysql with counting and limiting

开发者 https://www.devze.com 2023-03-15 14:29 出处:网络
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_F

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消