I successfully list rows, order by stars (3 stars first, 2 stars after and 1 star moreafter). However, I need to add rand. It should randomly show rows which have same stars.
select * from people order by stars desc limit 50
Here is how the table looks like:
id | name | stars
__________________
1---John---starstarstar
2---Mary---starstarstar
3---Tedy---starstarstar
4---Liam---starstar
5---Bery---starstar
What is the correct way to do it ?
SELECT * FROM people ORDER BY stars DESC, RAND() LIMIT 50;
You can simply use RAND()
.
select * from people order by RAND();