Posted By

BFTrick on 09/30/09


Tagged

mysql random query record weight weighted


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

dantreacy
kubaitis
virendrakryadav


Get random record based on weight


 / Published in: MySQL
 

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.

  1. SELECT * FROM Table ORDER BY RAND( ) * ( 1 / Weight )

Report this snippet  

You need to login to post a comment.