https://stackoverflow.com/questions/19412/how-to-request-a-random-row-in-sql

Solutions like Jeremies:

>

work, but they need a sequential scan of all the table (because the random value associated with each row needs to be calculated - so that the smallest one can be determined), which can be quite slow for even medium sized tables.

## MySQL select random records using ORDER BY RAND()

MySQL does not have any built-in statement to select random records from a database table. In order to accomplish this, you use the RAND function. The following query selects a random record from a database table:

Let’s examine the query in more detail.

• The RAND() function generates a random value for each row in the table.
• The ORDER BY clause sorts all rows in the table by the random number generated by the RAND()function.
• The LIMIT clause picks the first row in the result set sorted randomly.