Skip to content

Instantly share code, notes, and snippets.

@djburdick
Created April 22, 2013 20:09
Show Gist options
  • Select an option

  • Save djburdick/5438089 to your computer and use it in GitHub Desktop.

Select an option

Save djburdick/5438089 to your computer and use it in GitHub Desktop.
mysql select table by probability. #mysql
SELECT * FROM `table` ORDER BY RAND()*probability desc LIMIT 1;
probability is a number from 0 to 1
@djburdick
Copy link
Copy Markdown
Author

needs to be tested. RAND() may actually be run on each record, throwing off the probability

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment