Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

best way to select several mysql table rows at random?

Community Beginner ,
Jul 11, 2011 Jul 11, 2011

What is the best and quickest way to have one form button select multiple rows from a table with complete randomness?

Can you also offer some explanation (or link to a good tutorial)- I am a beginner in myql and php.

thanks

p.s. the id column in my table is auto incrementing and has some gaps (due to deletions of records). I do not want any of those gaps to be chosen at random (can they?).

TOPICS
Server side applications
290
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 11, 2011 Jul 11, 2011
LATEST

What do you have so far? How many rows will your table have and how many do you want to randomize? To produce random result without filter will put a strain on your server, especially if you have a lot of rows and you get a lot of server requests (pageloads). To randomize the results you basically have to recreate the table dynamically then output the result as an array. Again, this will put a huge load on your server. This may sound silly and ridiculously obvious, but have you tried searching the obvious term on google for MySQL random? There are millions of articles that describe the subject. Many first page results will show you exactly what you need to do. Try searching first then if you have trouble ask here, referencing the article you followed by first searching google.

best,

Shocker

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines