Created
April 22, 2013 20:09
-
-
Save djburdick/5438089 to your computer and use it in GitHub Desktop.
mysql select table by probability. #mysql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT * FROM `table` ORDER BY RAND()*probability desc LIMIT 1; | |
| probability is a number from 0 to 1 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
needs to be tested. RAND() may actually be run on each record, throwing off the probability