English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I want to do something like on Google/MSN/Yahoo where they display in advance the number of estimated rows/pages without actually counting them.

2006-08-06 09:04:54 · 3 answers · asked by daryn_mg2000 1 in Computers & Internet Programming & Design

3 answers

I found this is 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 get this row count, include a SQL_CALC_FOUND_ROWS option in the SELECT statement, then invoke FOUND_ROWS() afterward:

mysql> SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name
WHERE id > 100 LIMIT 10;

mysql> SELECT FOUND_ROWS();

So you can get the first n items and also the total number of items from just 2 lines. I'm guessing SQL_CALC_FOUND_ROWS and FOUND_ROWS() (or some equivalent) is available in mostSQL databases.

2006-08-06 10:43:10 · answer #1 · answered by sheeple_rancher 5 · 0 0

SQL does not know how to estimate a value. You would need to supply your own equation to estimate the number of rows. Otherwise just let SQL count the exact number.

2006-08-06 10:06:25 · answer #2 · answered by rscanner 6 · 0 0

John Cena vs side Please the heritage those 2 have had in 2006. it may to tremendous to be certain them feud one very last time. As Cena is truly one of the suitable face contained in the WWE and side because the suitable heel, it may be an outstanding rivalry.

2016-11-23 13:09:33 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers