View Single Post
Old 07-18-2003, 05:23 PM  
richard
Confirmed User
 
Join Date: Feb 2001
Location: UK
Posts: 543
MYSQL Gurus.... i need adivce

I'm using mysql 4, and want to use the new FOUND_ROWS() to find out the number of rows the query would have returned if i did not use limit.

Lets say i have 100 members, and i want to display 10 of them per HTML page, so i'm doing something like:

SELECT SQL_CALC_FOUND_ROWS * from my_table LIMIT 0,10;

I then want to do a 2nd query,

SELECT FOUND_ROWS();

to get the total number of results for my first query. (ie, i get 10 results, and now know how many total results i have, hence the number of pages of results).

Would i be correct in thinking i should aquire a WRITE LOCK on the table before doing both SELECT queries? (my thinking being another process could perform another SELECT query on the table in between the first and second query, which would change the FOUND_ROWS() result...).

?

How otherwise would you suggest i do this?

Richard.
__________________
richard is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote