Select random rows from a table in MySQL

In order to select a random row from MySQL, we can order the rows by a random number and then pick the first row.

SELECT * FROM node ORDER BY rand() limit 1;

The above query randomly selects a row from the table node.

12 May, 2010
Comments (0)
You may also like
On Facebook
Email Newsletter