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
2009-10-21 15:16:47
Great answer, thanks...
Andy E
2009-10-22 11:16:06
got minus 2 for this ;-( why on earth?
Tzury Bar Yochay
2009-10-22 16:05:09
+2
A:
Here is a webpage discussing this problem: http://akinas.com/pages/en/blog/mysql%5Frandom%5Frow/
HTH
StarWind Software
2009-10-21 16:23:06