Home > Selecting a random row with MySQL
Selecting a random row with MySQL
29th September 2009
God bless you, MySQL. You're one crazy DBMS. You can actually ORDER BY the RAND() function to get a dataset ordered randomly.
SELECT * FROM T ORDER BY RAND() LIMIT 1;
This selects a random row from table T. Couldn't be easier.