Get random record based on weight


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

Must have a field named Weight. The more Weight the more often the record is selected. Weight should be an integer between 1 and 10.


Copy this code and paste it in your HTML
  1. SELECT * FROM Table ORDER BY Rand( ) * ( 1 / Weight )

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.