Reputation: 103
I need take from MYSQL 5 values that taked from top 10 values randomly?
Exmple: I'v 100 posts in my db and I want take 5 of them that have views number in top 10 posts. How can I do it by only one command in mysql?
Upvotes: 2
Views: 57
Reputation: 591
SELECT * FROM
(SELECT * FROM posts order by id DESC limit 0,10) as p1
ORDER BY rand() limit 0,5
Please change fields according your database structure
Upvotes: 1