LIMIT then RAND rather than RAND then LIMIT

Posted by Larry on Stack Overflow See other posts from Stack Overflow or by Larry
Published on 2010-04-15T18:44:48Z Indexed on 2010/04/15 19:53 UTC
Read the original article Hit count: 532

Filed under:
|
|

I'm using full text search to pull rows.
I order the rows based on score (ORDER BY SCORE) , then of the top 20 rows (LIMIT 20), I want to rand (RAND) the result set.

So for any specific search term, I want to randomly show 5 of the top 20 results.

My workaround is code based- where I put the top 20 into an array then randomly select 5.

Is there sql way to do this?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about rand