My table has many row that have a same column. I’ll call the column “likes”. If I use “order by likes”, then the rows with the same “likes” will be ordered by the time they were added to the database.
I want all rows with the same “likes” to be sorted randomly. I tried “ORDER BY likes, rand()”, but everything is being sorted randomly.
How can I do this?
My table has many row that have a same column. I’ll call the column
Share
I suggest you check again. Adding the clause
order by something, rand()to one of my queries acts exactly as you would expect, with the only randomising happening within asomethinggroup.Just be aware that using
rand()in anorder byclause will not scale very well as your table gets bigger.