I want to fetch only 20 rows from a database table using one condition for example :
select * from orders where price > 10000 limit 0,20
Above query w开发者_运维技巧ill fetch only 20 rows. Is there any way i can get how many rows it can fetch with same condition in WHERE clause when limit 0,20
is not used?. I have to do it in one single query.
Please guide me.
Thanks..
To quote the MySQL docs:
A SELECT statement may include a LIMIT clause to restrict the number of rows the server returns to the client. In some cases, it is desirable to know how many rows the statement would have returned without the LIMIT, but without running the statement again. To obtain this row count, include a SQL_CALC_FOUND_ROWS option in the SELECT statement, and then invoke FOUND_ROWS() afterward.
This?
select count(*) from orders where price > 10000
精彩评论