You get a bonus - 1 coin for daily activity. Now you have 1 coin

How to get the total result count of a query with LIMIT in MySQL

Practice




How to find out the total number of results in MySQL with a LIMIT query

Select * from table where a=1 limit 5,10

and the total number of rows with where a=1, for example, 50
how do I find out that it's 50?
either with two queries or with one

SELECT SQL_CALC_FOUND_ROWS * from table where a=1 limit 5,10


SELECT FOUND_ROWS();


or with one query you can do it like this,3 but probably it's not such a good idea



SELECT SQL_CALC_FOUND_ROWS *, FOUND_ROWS() as count_total from table where a=1 limit 5,10

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Databases - MySql (Maria DB)"

Terms: Databases - MySql (Maria DB)