Answer the question
In order to leave comments, you need to log in
How to make a selection with LIMIT and counting records in one query?
The task is typical, pagination of records from the database.
Make a selection of records with a limit and count how many records in total fall under this condition.
Standard Solution:
SELECT * FROM users WHERE status > 0 limit 10;
SELECT COUNT(*) FROM users WHERE status > 0;
Answer the question
In order to leave comments, you need to log in
SELECT count(*) over() as total, status FROM users WHERE status > 0 limit 10;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question