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 downloa开发者_Go百科ded items, choose 16 at random and return that in the result. Is that possible with just one query?
SELECT *
FROM (SELECT FROM table ORDER BY download_no DESC LIMIT 50) AS new_table
ORDER BY RAND()
LIMIT 16
Here is a webpage discussing this problem: http://akinas.com/pages/en/blog/mysql_random_row/
HTH
ORDER BY RAND()
精彩评论