Jump to content

Random Records Using MySQL


stevesimo

Recommended Posts

Hi, I have a quick question regarding random records in MySQL.  Say for example I have 25 records and I want to start from a random record position such as 16.

 

Is there a command in Mysql to jump to a specific record such as goto or moveto?

 

I know when I was using ASP there was a goto(rec num) command where you could jump to individual records within the record set.

 

Many thanks,

 

Steve

Link to comment
Share on other sites

What I am trying to achieve is to have my results in alphabetical order but have the starting position random.  So suppose there are 25 records in my result set with 10 on a page I will have 3 pages of results.  Each time the search is carried out, the starting position of the results will be random.  So page 1 might start with records beginning with S or M etc.  The reason that I want to do this is I want the results to be unbiased.  Most sites order results either alphabetically or by record ID.  This way it doesnt matter what your name is or when your record was added, everyone has a fair chance of appearing on page 1 as much as the next person.

 

My question is simply does MySQL have a command which allows you to jump to an individual record with a result set?  As long as I know how many records are in the result set and what the starting position is, I can page my results.  All I need to be able to do is get to the starting record in the first place.  I could use a loop to achieve this but this is inefficient and unnecessary.  Anyone got any ideas how I can do this?

 

Thanks in advance (Steve - Blackpool)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.