Randomly (with weight bias) select row from database? [duplicate]
Possible Duplicate:
MySQL: Select Random Entry, but Weight Towards Certain Entries
I have a table that I would like to be able to randomly select a user from, but in this table I have an 'Entries' column. I have been able to randomly select a user, but now I am trying to take into account their number of entries (higher the number, the more likely they are to win). How would I go about doing this?
My table looks so开发者_开发技巧mething like:
FN | LN | ENTRIES
Bob | Smith | 20
John | Doe | 3
Thanks for your help!
To weight them, multiply rand() by the entries column..
select * from table order by entries*rand() desc limit 1;
精彩评论