My thanks to Paul DuBois, who responded within about a minute of my first posting. :>
(Original question below.)

The solution is that "SQL_CALC_FOUND_ROWS" needs to be included in the original SELECT 
query in order for FOUND_ROWS() to have the proper value.


SELECT SQL_CALC_FOUND_ROWS col1, col2
FROM tbl
WHERE col2 > 2
LIMIT 10;

You'll get back 10 rows.

SELECT FOUND_ROWS();

You should get back a value of 32.

Note that there's no comma after SQL_CALC_FOUND_ROWS.



---- original question ---

At 11:21 PM -0500 10/31/01, Robert Alexander wrote:
>Hi all,
>
>In the 4.0 manual, section F.1.1 "Changes in release 4.0" it says:
>
>"Added SQL_CALC_FOUND_ROWS and FOUND_ROWS(). This makes it possible to know how many 
>rows a query would have returned without a LIMIT clause."
>
>Unfortunately, I can't find any other references to FOUND_ROWS() in the manual, or 
>when I do a search for it in the documentation on the MySQL site.
>
>This function would be very handy for me in an application I'm working on.
>
>I tried it in the client, for example:
>
>mysql> select col1, col2
>     -> from tbl
>     -> where col2 > 5
>     -> limit 10;
>
>And I got 10 rows back.
>
>I then did:
>
>mysql> select found_rows();
>            -> 10
>
>then;
>
>mysql> select col1, col2
>     -> from tbl
>     -> where col2 > 5
>
>and got back 32 rows
>
>mysql> select found_rows();
>            -> 32
>
>This doesn't seems to be working as the brief description would seem to indicate.
>
>What am I missing?
--
Robert Alexander    ~~   Programmer/Analyst/DBA/Admin
WWW Database Applications    ~~    http://www.ra1.net
Web Software and Hosting   ~~  http://www.workmate.ca

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to