tags:

views:

135

answers:

3

I want to display a list of 16 of the most popular items in my database, but I want that list to be different every time. So from say, the top 50 downloaded items, choose 16 at random and return that in the result. Is that possible with just one query?

+12  A: 
SELECT * 
    FROM (SELECT FROM table ORDER BY download_no DESC LIMIT 50) AS new_table
    ORDER BY RAND() 
    LIMIT 16
Residuum
A: 

ORDER BY RAND()

Tzury Bar Yochay
Great answer, thanks...
Andy E
got minus 2 for this ;-( why on earth?
Tzury Bar Yochay
+2  A: 

Here is a webpage discussing this problem: http://akinas.com/pages/en/blog/mysql%5Frandom%5Frow/

HTH

StarWind Software
Thank you, very useful but I decided to go with Residuum's answer.
Andy E