开发者

mysql selection preference

I'm wanting to display random adverts on my front 开发者_运维技巧end that are selected from a table. Each advert has a score between 1 and 5. The higher the advert score, the more frequently it should be selected

Is there any way I could achieve this in a query? So maybe something like

SELECT * FROM advert ORDER BY RAND(), (SOME MAGICAL PREFERENCE ORDERING) LIMIT 3

Thanks!


How about

SELECT * FROM advert ORDER BY RAND() * (SOME MAGICAL PREFERENCE ORDERING) DESC LIMIT 3
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜