Record Casuale

Per ottenere un record casuale c'è un semplice metodo SQL senza bisogno di affidarsi a funzioni (es: PHP) che aggiungono inevitabilmente un overhead.

SELECT * FROM tablename 
ORDER BY RAND() LIMIT 1 

Oppure

SELECT * FROM tablename 
WHERE somefield='something' 
ORDER BY RAND() LIMIT 1

Non è una query molto efficiente ma funziona.