FOUND_ROWS() in Multiple Users Environmnent
am 14.03.2006 17:53:36 von howa
Hi,
Suppose many users will issue SELECT statement to the server, e.g.
1. UserA issued a SELECT statement
2. UserA issued FOUND_ROWS() and get the correct result
The above is okay, but problems might occur when there is more than one
users
1. UserA issued a SELECT statement
2. UserB issued another SELECT statement
3. UserA issued FOUND_ROWS() and will get the wrong result??
how to handle this?
Thanks.
Re: FOUND_ROWS() in Multiple Users Environmnent
am 14.03.2006 18:55:03 von Bill Karwin
wrote in message
news:1142355216.214712.304810@i39g2000cwa.googlegroups.com.. .
> 1. UserA issued a SELECT statement
> 2. UserB issued another SELECT statement
> 3. UserA issued FOUND_ROWS() and will get the wrong result??
>
> how to handle this?
FOUND_ROWS() is supposed to be similar to LAST_INSERT_ID(), in that it gives
the correct answer in the context of a given connection, even if other
statements are being executed on different connections.
Try this experiment: open two command windows, and run the mysql shell in
each window. Execute a query in shell A that returns N rows. Then execute
a query in shell B that returns some different number of rows. Then go back
to shell A and execute "SELECT FOUND_ROWS();". It should return the value N
of the previous query you executed in that shell, even though another query
has been executed in the meantime in shell B.
Note that executing "SELECT FOUND_ROWS();" again always returns the answer
1, because that's how many rows were returned by "SELECT FOUND_ROWS();".
Regards,
Bill K.