1.

You Wrote A Search Engine That Should Retrieve 10 Results At A Time, But At The Same Time You'd Like To Know How Many Rows There're Total. How Do You Display That To The User?

Answer»

SELECT SQL_CALC_FOUND_ROWS page_title FROM web_pages LIMIT 1,10; SELECT FOUND_ROWS(); The SECOND query (not that COUNT() is never used) will TELL you how many RESULTS there’re total, so you can display a PHRASE "Found 13,450,600 results, displaying 1-10". Note that FOUND_ROWS does not pay attention to the LIMITS you specified and always returns the total number of rows affected by query.

SELECT SQL_CALC_FOUND_ROWS page_title FROM web_pages LIMIT 1,10; SELECT FOUND_ROWS(); The second query (not that COUNT() is never used) will tell you how many results there’re total, so you can display a phrase "Found 13,450,600 results, displaying 1-10". Note that FOUND_ROWS does not pay attention to the LIMITs you specified and always returns the total number of rows affected by query.



Discussion

No Comment Found