开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜