Selecting a random row with MySQL

Posted:

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.