I do not understand if this is what you want, but if it is just the numbering of the output lines, you can do something like this:
SELECT
@linha := @linha + 1 AS contador,
tabela_desejada.*
FROM
(SELECT @linha := 35) AS nada,
-- ^ Usar o mesmo valor inicial do limit
tabela_desejada
LIMIT 35,10;
-- ^ Usar o mesmo valor inicial da subquery
- Note that the subquery with the value of example 35 must use the same initial value of the limit. Probably, because the query will be generated dynamically, it is enough to use the same parameter in both places.
- Also remember that
limit
of MySQL starts from scratch.
To start from 1 at the output, just do ( @linha := @linha + 1 ) + 1 ...
Totalizer version:
SELECT
CONCAT( "#", @linha := @linha + 1, " de ", total.cnt ) AS ranking,
tabela_desejada.*
FROM
(SELECT @linha := 35) AS nada,
(SELECT COUNT(*) AS cnt FROM tabela_desejada) AS total,
tabela_desejada
ORDER BY nome
LIMIT 35,10;
In this case, if you are going to use WHERE
, remember to replicate the condition in query main and in subquery :
>
...
(SELECT COUNT(*) AS cnt FROM tabela_desejada WHERE id > 100) AS total,
-- ^ atenção
tabela_desejada
WHERE id > 100
-- ^ atenção
ORDER BY nome
LIMIT 35,10;