Re: Count all rows if limit by?

2004-03-22 Thread Victor Spång Arthursson
Thanks a lot, Jigal and Egor - just what i searched for!

Sincerely

Victor

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Count all rows if limit by?

2004-03-19 Thread Victor Spång Arthursson
Hi all!

Is there a simple way to get the total number of rows a result _should_ 
have had if no where-clause where present? Without doing a second 
query?

Sincerely

Victor

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: Count all rows if limit by?

2004-03-19 Thread Jigal van Hemert
From: Victor Spång Arthursson [EMAIL PROTECTED]
 Is there a simple way to get the total number of rows a result _should_
 have had if no where-clause where present? Without doing a second
 query?

Example from http://www.mysql.com/doc/en/Information_functions.html :

mysql SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name
   WHERE id  100 LIMIT 10;
mysql SELECT FOUND_ROWS();

Available since 4.0.0.; in versions prior to 4.1.0. this didn't work with
LIMIT 0.
Regards, Jigal.



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Count all rows if limit by?

2004-03-19 Thread Egor Egorov
Victor Sp?ng Arthursson [EMAIL PROTECTED] wrote:
 Hi all!
 
 Is there a simple way to get the total number of rows a result _should_ 
 have had if no where-clause where present? Without doing a second 
 query?
 

If you want to get total number of rows in the table (without WHERE and without LIMIT) 
you should execute
SELECT COUNT(*) FROM table_name;

If you want to obtain number of rows the statement would have returned without the 
LIMIT clause, you can specify SQL_CALC_FOUND_ROWS keyword in the SELECT statement and 
then use FOUND_ROWS() function:
http://www.mysql.com/doc/en/Information_functions.html



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Egor Egorov
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
   ___/   www.mysql.com




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]