FOUND_ROWS() in Multiple Users Environmnent

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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

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?


Re: FOUND_ROWS() in Multiple Users Environmnent

Quoted text here. Click to load it

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();".

Bill K.

Site Timeline