469,904 Members | 2,074 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

found_rows() everytime returns 1

hi to all
I use this query
SELECT SQL_CALC_FOUND_ROWS * FROM prods LIMIT 100,10;

I'd like to know how many rows this query returns without limit, but
using this
select FOUND_ROWS();
the result is everytime 1

You know why?
No other query are processed before the found_rows().
Thanks

--
Andrea

May 3 '06 #1
6 10922
Not an answer to your question, but I figured that I'd try and run it
on my server... here is my results.

I'm using: mysql Ver 12.22 Distrib 4.0.24, for pc-linux-gnu (x86_64)

I ran all of these queries in this exact sequence:

If I run 'select * from client;' I get 264 rows
If I run 'select found_rows();' I get the correct value of 264
If I run 'select * from client limit 100,10;' I will get 10 rows
If I run 'select found_rows();' I erroneously get 110

So I guess its pretty much broken... I'll stay away from it!

Jeach!

May 4 '06 #2
You haven't use the SQL_CALC_FOUND_ROWS.
In the manual you can find "If the preceding SELECT statement does not
include the SQL_CALC_FOUND_ROWS option, then FOUND_ROWS() may return a
different result when LIMIT is used than when it is not."
If you can, try with this option.

p.s. i use on my server mysql 5.0.18
--
Andrea

May 4 '06 #3
mmmhhhh
I ran the queries using the MySQL Query Browser software
(http://www.mysql.com/products/tools/query-browser/)
and the result of found_rows was 1.
I ran the two queries above in a php page and the count of rows was
correct. I have lost many time for this problem :(

--
Andrea

May 4 '06 #4
mmmhhhh
I ran the queries using the MySQL Query Browser software
(http://www.mysql.com/products/tools/query-browser/)
and the result of found_rows was 1.
I ran the two queries above in a php page and the count of rows was
correct. I have lost many time for this problem :(

--
Andrea

May 4 '06 #5
mmmhhhh
I ran the queries using the MySQL Query Browser software
(http://www.mysql.com/products/tools/query-browser/)
and the result of found_rows was 1.
I ran the two queries above in a php page and the count of rows was
correct. I have lost many time for this problem :(

--
Andrea

May 4 '06 #6
andrea azzini wrote:
I ran the queries using the MySQL Query Browser software
(http://www.mysql.com/products/tools/query-browser/)
and the result of found_rows was 1.


MySQL Query Browser opens a new connection for each statement you
execute. The value returned by FOUND_ROWS() is relevant only during the
current connection. So there is no way to use this function in MySQL
Query Browser; you must use the command-line tool 'mysql'.

FWIW, the same issue happens when trying to use other session-dependent
features in MySQL Query Browser, such as LAST_INSERT_ID() and user
variables.

Regards,
Bill K.
May 4 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by David Lozzi | last post: by
9 posts views Thread by Achintya | last post: by
6 posts views Thread by crack.the.hack | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.