开发者

MySQL query to get random rows but with taking a score into account

I have a large database of links to pages and I'm trying to select 20 of them randomly but I also want to take a score (or influence) into account when doing so.

Right now all of the links start with a score of 100 and I want links with a score of 200 to be twice 开发者_开发问答as likely to show in the results. Also links with a score of 50 I want to be half as likely to show vs a score of 100.

I can change my score system if this isn't the proper way to do this type of system but does anyone have any idea how I can accomplish this properly?


SELECT link FROM table
ORDER BY RAND() * SCORE DESC
LIMIT 20
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜