I want to catch X rows, thus, I set LIMIT X
; but how can I simultaneously count the total number of rows too?
Currently, I use two separate queries to do so as
SELECT COUNT(*) FROM col WHERE CLAUSE
SELECT * FROM col WHERE CLAUSE LIMIT X
Is there a way to do this in one query?
EDIT: The output should be the col
cells and the number of rows. In fact, after selecting the col
cells, it should walk over the table to count only.
I know that it is not possible to merge these two queries, as the first return 1 row, but the second X rows. I am curious if there is a function in mysql to return the number of rows in the presence of LIMIT
.