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
精彩评论