Get Random Record Based on Weight


/ Published in: MySQL
Save to your folder(s)

This snippet allows you to get random record from given table by weight. To run it, it must have a field named "weight". The more "weight" is assigned, the more often the record is selected. The value of "weight" should be an integer between 1 and 10 (or anything else).

URL: http://www.apphp.com/index.php?snippet=mysql-get-random-record-based-on-weight

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.