Forum Moderators: coopster
I'm sorry if this has been asked before, but I can't seem to find an answer to my problem.
Basically I want to have say 50 'pages' (although it would just be resubmitting to itself) where each page grabs data from one random row. I could do this simply by choosing a random row and then getting the data for that random row and displaying it. However, this would mean having 50 select statements and would really slow things down. I cannot pre-generate the random sequence and pass it with the URL as it needs to be hidden. I looked into paging, but this just does what I have already, performing a select for each page.
Is there anyway how I can just do one select query to grab the data for all 50 rows, and then use a row of this data one at a time for each page? Hopefully this makes sense! Thanks for any help =)
Be aware that ORDER BY RAND() is horrendously inefficient in certain cases and it would be better to dynamically build a query with 50 random key values pre-generated (a,b,c,d etc), then use a SELECT * FROM blah WHERE KEY IN(a,b,c,d...) for example, depending on how exacly your primary key field is constructed and the distribution of values within it.