Does not "return". COUNT()
results in the total amount of items that he found to satisfy the established query. How much information is it? One . Only the total amount, a single value. When you say you despise a value, you are already despising everything that has resulted, so it makes sense to have this behavior. It does not make sense to use OFFSET
with COUNT()
.
If you want to know how many rows the query has been, you can do this:
SELECT COUNT(*) AS total FROM (SELECT 1 FROM noticias ORDER BY data_noticia DESC LIMIT 30 OFFSET 2) AS resultado;
You make your query and the result of it you make the account. Remember that it will give a value up to 30. If you have more than 30 it will always be 30.
I can not guarantee it's the best way, but the basis is this.
If you are effectively picking up the data from the first query, you can count how many rows were delivered by the database to your application directly in the application. You can get the array size or you can use the mysqli_num_rows()
.